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
Hard disk works on the following technologies: (i) Technology used within the hard drive to read &amp; write data to the drive a
Alex787 [66]

Answer:

The green-blue circuit board you can see in the first photo includes the disk controller, a circuit that allows the computer to operate the drive's mechanisms and read/write data to and from it. ... A small hard drive typically has only one platter, but each side of it has a magnetic coating

Explanation:

8 0
3 years ago
The Counter Pattern
kumpel [21]
You'll probably see numbers counting up, like 1 2 3 4 ...
6 0
3 years ago
According to shared security model, which two are a customer's responsibilities in Oracle Cloud Infrastructure (OCI)?
sashaice [31]

Answer:

According to shared security model, a customer's responsibilities in Oracle Cloud Infrastructure (OCI) are:

1. Workloads security: The customer is responsible for protecting the work function or a distinct capacity, like a Hadoop node, a Web server, a database, or a container, that it puts on the cloud.

2. Services configuration:  The customer is also responsible for securing the specifications that describe the different aspects of its managed service.

Explanation:

Responsibilities are shared between Oracle and the customers using the Oracle Cloud Infrastructure (OCI).  Oracle is solely responsible for the security of the underlying cloud infrastructure (such as data-center facilities, hardware, and software systems), while the customer is responsible for securing the workloads and configuring their services to suit their individual needs.

8 0
3 years ago
B. Write your thoughts about the following in your notebook.
tankabanditka [31]

1. stay with adult supervision

2. check on the web and create a site for it

3. quickly remove it and try not to read it

Explanation:

I really hope this helps

please mark as brainliest

4 0
3 years ago
To successfully operate a scanner, what will you need to do first?
Alinara [238K]

For the scanner to be successfully operated, there is need to first install the necessary software.

Computer scanner belongs the Input category of Computer system.

The main function of Scanner includes:

  • Enables scanning or taking of a picture or document.
  • Its helps to digitize the Hard copies.

So, there is a need to first install the scanner software on the system to establish and allow exchange of instruction between the Scanner and the Computer system.

In conclusion, the Correct Option is D because there is need to first install the scanner software on the system.

Learn more about Scanner here

<em>brainly.com/question/10097616</em>

8 0
2 years ago
Other questions:
  • Most programming languages provide loop statements that help users iteratively process code. In Coral you can write loops that h
    15·1 answer
  • How are different types of cars similar and different?
    10·1 answer
  • WHERE WAS THE CHEESEBURGER INVENTED?
    9·1 answer
  • To close the ____ view, click File on the Ribbon or click the preview of the document in the Info gallery to return to the docum
    9·1 answer
  • Purpose: This application provides experience with user input and interaction in the Console, writing files to disk, working wit
    9·1 answer
  • Which of the following problems is least likely to be solved through grid computing? Financial risk modeling Gene analysis Linea
    14·1 answer
  • What is a multipurpose network device?
    10·1 answer
  • What is the best way to show a complex data chart in word?
    6·1 answer
  • he primary purpose of a database query is to a. find and retrieve specific information. b. correct information in the database.
    9·1 answer
  • missy just hired a software development team to create an educational simulation app for a high school course. she has specific
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!