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
ZanzabumX [31]
3 years ago
11

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 (such as Dinner, Conference, Lodging, and so on), the amount of the sale, and the date of that event. Write a java program that reads such a file and displays the total amount for each service category. Display an error if the file does not exist or the format is incorrect. Make sure the program can read a text file and that writes a separate file for each service category, containing the entries for that category. Name the output files Dinner.txt, Conference.txt, and so on.
Computers and Technology
1 answer:
Paul [167]3 years ago
7 0

Answer:

Complete solution is given below:

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
How can you add and remove categories from a previously created chart? A. Click the Format tab. B. Click the Chart Styles button
hoa [83]
<span>Click the Chart Filters button.</span>
7 0
3 years ago
Read 2 more answers
A small company with 100 computers has hired you to install a local area network. All of the users perform functions like email,
charle [14.2K]

Answer:

Answer to the following question is as follows;

Explanation:

Windows 7 for 100 users and Windows 8.1 for 25 users are the best options since they both enable networking and active directory, and Windows 8.1 also offers Windows server capabilities.

Winxp would therefore work for $100, but it is unsupported and has no updates.

If you wish to go with open source, you can choose Ubuntu 16 or 18 or Linux.

8 0
3 years ago
What is the output of the following program?
Minchanka [31]

Answer:

the answer is t

Explanation:

7 0
3 years ago
What TYPE of flash drive is called when it saves your files safely? I'm going to use my friend computer that's why.
Lilit [14]

Answer:

A good Universal serial bus i use is a San Disk

Explanation:

others are a WD easystore, A samsung MUF-BA.... etc

8 0
3 years ago
Why is computer called information processing machine....?​
mixer [17]

Answer:

Since the computer accepts raw data as input and converts into information by means of data processing

Explanation:

helping!!!

3 0
2 years ago
Read 2 more answers
Other questions:
  • Susan will be configuring a snort network ids sensor to monitor her subnetwork. she will be using a web-based console interface
    8·1 answer
  • during zach's second visit of the year, he incurred a $450 bill. Describe how much is paid by Zach and the insurance carrier
    7·1 answer
  • Write an algorithm in pseudocode (following the style of the Minimax pseudocode) that will always make an optimal decision given
    13·1 answer
  • Pinterest, a visual bookmarking Website, logs more than 14 terabytes of new data each day, which means its storage needs are con
    10·1 answer
  • Among the following, which is the best protection against ransomware?
    8·1 answer
  • WILL GIVE BRAINLIEST!!!!!! 10 POINTS!!!!
    14·2 answers
  • A transistor may be used as an amplifier in an electronic circuit. <br> Select one: True False
    12·1 answer
  • How does social network use message to entertain?
    14·1 answer
  • b. Write a complete program for the following situation related to setting the speed of a car to preset values before starting a
    5·1 answer
  • For a certain company, the cost function for producing x items is C(x)=50x+100 and the revenue function for selling x items is R
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!