1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zepelin [54]
3 years ago
7

A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: the name of the clie

nt the service sold ( Dinner, Conference, Lodging) the amount of the sale the date of the event. Write a program that reads such a file and displays the total amount of each service category. Display an error if the file does not exist or the format is incorrect. Homework
Computers and Technology
1 answer:
timama [110]3 years ago
3 0

Answer:

see explaination

Explanation:

Java code

//Header file section

import java.util.Scanner;

import java.io.*;

//main class

public class SalesTestDemo

{

//main method

public static void main(String[] args) throws IOException

{

String inFile;

String line;

double total = 0;

Scanner scn = new Scanner(System.in);

//Read input file name

System.out.print("Enter input file Name: ");

inFile = scn.nextLine();

FileReader fr = new FileReader(new File(inFile));

BufferedReader br = new BufferedReader(fr);

System.out.println("Name \t\tService_Sold \tAmount \tEvent Date");

System.out.println("=====================================================");

line = br.readLine();

//Each line contains the following, separated by semicolons:

//The name of the client, the service sold

//(such as Dinner, Conference, Lodging, and so on)

while(line != null)

{

String temp[] = line.split(";");

for(int i = 0; i < temp.length; i++)

{

System.out.print(temp[i]+"\t");

if(i == 1)

System.out.print("\t");

}

//Calculate total amount for each service category

total += Double.parseDouble(temp[2]);

System.out.println();

line = br.readLine();

}

//Display total amount

System.out.println("\nTotal amount for each service category: "+total);

}

}

inputSale.txt:

Peter;Dinner;1500;30/03/2016

Bill;Conference;100.00;29/03/2016

Scott;Lodging;1200;29/03/2016

Output:

Enter input file Name: inputSale.txt

Name Service_Sold Amount Event Date

=====================================================

Peter Dinner 1500 30/03/2016

Bill Conference 100.00 29/03/2016

Scott Lodging 1200 29/03/2016

Total amount for each service category: 2800.0

You might be interested in
If you have access to an ssn, but do not have permission to view certain folders or documents in that ssn, those folders and doc
hodyreva [135]
<span>If I remember it correct, if you have access to an ssn, but do not have permission to view certain folders or documents in that ssn, those folders and documents will be hidden. Or it depends on OS. But in most ways its hidden or masked.</span>
5 0
3 years ago
Read 2 more answers
What is an Array? 20 POINTS!!!
EastWind [94]

Answer:

I'm about 99% sure it's C: a unique address or location un the collection

6 0
2 years ago
Katrina studied hard for a biology test about the anatomy of a frog, but she did poorly and is using the "glows and grows” strat
melomori [17]

Answer:

how the frog grows through its life

Explanation:

7 0
2 years ago
What is the size of the rc.conf file in bytes
jasenka [17]

In the case above, the size of the rc.conf file in bytes is said to be 281 bytes.

<h3>What is rc conf file?</h3>

The rc. conf file is known to be a file that often specifies the kind of services that needs to  be enabled in course of system startup by the startup scripts that was invoked by /etc/rc (see rc(8)), and that also ashutdown scripts that is said to be invoked by /etc/rc. shutdown.

Note that In the case above, the size of the rc.conf file in bytes is said to be 281 bytes.

Learn more about bytes from

brainly.com/question/6835146

#SPJ11

3 0
2 years ago
Read 2 more answers
When setting the ISO on the camera, what ISO would contain the most grain?
andrezito [222]

Answer:

D

Explanation:

The ISO values on a roll of film or ISO setting on a digital camera are these indicators. ... A higher ISO had larger, jagged grains of salt, thus producing “rougher” or ... In digital photography, the same logic applies… the lower the ISO rating, the higher the ISO rating (more sensitive) the stronger the image sensor has to ...

6 0
3 years ago
Other questions:
  • Need help with this file and due today!!
    6·1 answer
  • Computer Architecture
    7·1 answer
  • Write a Bare Bones program that takes as input two variables X and Y. (Again, assume these values are set before your program be
    10·2 answers
  • What is the Purpose and function of the Global Positioning System (GPS)?
    7·1 answer
  • &gt;What is the output of the following code:
    5·1 answer
  • How has your perspective changed since the beginning of the class?
    5·1 answer
  • The following code is intended to test whether the int variable num is less than 10, and if so print a warning and set it to 10.
    6·1 answer
  • Using these Web sites for guidance, write a definition in your own words for five of the terms listed below.
    8·1 answer
  • takes the perspective that a program describes what the solution to a problem is, not how that problem is solved. Select one: a.
    5·1 answer
  • Which best compares portrait and landscape orientations?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!