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
Which View option allows you to view your document as it would appear when posted online?
kondaur [170]

I assume this is in regards to Microsoft Word?


If so, then the Web Layout view will allow you to view the document as it would look on a webpage.

3 0
4 years ago
What will help the programmer understand what’s going on in the program?
Over [174]

Answer:

Programming languages to help solve algorithms

Explanation:

6 0
3 years ago
Which conditional tab would you use to add a quick style to a form or report? Arrange Design Format Page Setup
Vilka [71]

Answer:Format

Explanation:

5 0
3 years ago
The purpose of the ________ element is used to configure the headings for a web page document or section of a web page document.
Vesnalui [34]
The answer would be "Inspect"
7 0
4 years ago
Select the answer that best describes the activity
Anastasy [175]

Answer:

software piracy

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Think of a game you are familiar with and identify at least three team responsibilities which were required to make the game, on
    5·1 answer
  • How do you take a screen shot on hp pavilion dm3
    12·1 answer
  • Does anyone know in adobe photoshop , digital design class , how to make a smart object and copy it to another page!
    6·1 answer
  • Which part of the computer stores and processes data?
    14·1 answer
  • Project: Baseline, Benchmark, Objective, and Goal
    14·2 answers
  • Websites not only give us information, but they also inspire designers in their layouts, illustrations, images, typefaces, and c
    6·1 answer
  • Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should NOT
    10·1 answer
  • Which are the correct commands to create and run an ReactJS project?
    10·1 answer
  • What is an Array? 20 POINTS!!!
    15·1 answer
  • Yuki is preparing to write a research paper for his english class. which style guide would be best for him to use? american psyc
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!