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]
2 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]2 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
What should be a technicians first step in an A/C system
hram777 [196]
A technician's first step with an A/C system is to perform visual inspection
8 0
3 years ago
Hey good to mett you
ella [17]

Answer:

You too?

Explanation:

4 0
2 years ago
Can some one fix this <br> input ("Enter a number: ") <br> print (num * 8)
Kaylis [27]
If you save the input as num,
this will print the input 8 times.

num = input("Enter a number: ")
print(num * 8)

If you want to do actual math calculations,
then the input needs to be a number.

num = float(input("Enter a number: "))
print(num * 8)

This doesn't account for any errors in which the user doesn't input a number, but I don't think that's what you were looking for anyway :)
6 0
2 years ago
Please NEED HELP ASAP WILL MARK BRAINLIEST ONLY #8
ValentinkaMS [17]

Answer:

I think its A

Explanation:

6 0
2 years ago
The browser feature which enables tabs to work independently from one another so if one crashes, the others may continue to work
Mars2501 [29]

Answer:

Tab isolation

Explanation:

Tab isolation is a feature of the browser that works to protect your data from malware. its uses to enhance the reliability of the browser by considering the impact of the crash.

A browser without the tab isolation can be crash fully due to the crashing of one tab. this feature helps to recover the previous opening tab after crashing while on the previous version of the browser if one tab crashes then it automatically crashes all other tabs.

8 0
3 years ago
Other questions:
  • In 125 words describe the steps to active listening.
    6·1 answer
  • Which of the following is a unique feature of Object-oriented programming?
    6·2 answers
  • The global network that links millions of computers is the
    9·2 answers
  • An equation that performs a calculation is a formula. True or false quest
    9·1 answer
  • How many characters does the "short text" have?
    9·1 answer
  • The ______ printers are the most popular type of printer in small office/home office and large office environments.
    5·1 answer
  • What is the positional weigh of the digit 7 in the octal number 7642 ?​
    15·1 answer
  • Using C, Write a program that reads a series of strings from standard input and prints only those strings beginning with the let
    8·1 answer
  • A web-based program that uses artificial intelligence techniques to automate tasks such as searches is called
    8·1 answer
  • Can anyone figure this out???? I need help ASAP!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!