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
Write a query to show the price reduced by 10% for all products that are tables or entertainment centers with a standard price g
IceJOKER [234]

Answer:

Below is the required code:

Explanation:

SELECT Product_Finish AS "Desk Finish",

avg(Standard_Price) AS "Average Price"

FROM Product_T

WHERE "Average Price">200

ORDER BY "Average Price" DESC;

8 0
3 years ago
Simpson is trying to solve an equation related to converting a decimal number to its hexadecimal form. He decides to utilize the
Murljashka [212]

Answer:

the answer is A.

6 0
3 years ago
A ________ is a virus that is triggered on a certain date.
marysya [2.9K]
A time bomb virus is a virus that is triggered on a certain date. It is a malicious program that is designed to release virus unto a system. Once the time has arrived, it will automatically start working what it is programmed to do since any virus could do anything depending on what it is designed to do.
8 0
3 years ago
While reviewing some web page code, you notice that the html is written in all lowercase letters. you are not sure which version
Sphinxa [80]
<span>To verify the version of HTML being run on any given page, check the DOCTYPE declaration at the head of the file. Use "inspect element" to view the page source; the DOCTYPE is generally in the header.</span>
5 0
3 years ago
Question 17 (3 points)
Archy [21]

Answer:

#

Explanation:

6 0
2 years ago
Other questions:
  • How to fix Please enable JS and disable any ad blocker
    13·2 answers
  • Yesterday you installed a new game on your computer. When you ran the computer, you noticed that the application was running ver
    15·1 answer
  • If you wanted to have wireless connectivity in your home or​ apartment, you would need a​ _________________ to move packets of d
    11·1 answer
  • A command, such as a button or keyboard shortcut, that performs a specific task is known as a
    9·2 answers
  • Write a function called count_occurrences that takes two strings. The second string should only be one character long. The funct
    13·1 answer
  • Write a program that prompts the user to enter a grade, which is aninteger in the range of 0 - 100. Using if statements, have th
    11·1 answer
  • How do you think weather can affect sailing?<br><br>What would be good sailing weather?​
    9·1 answer
  • Two types of are desktop computers and notebook computer
    11·2 answers
  • What is the name of the device protected by a digital certificate?
    10·1 answer
  • What is 2+2 I need to know hurry
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!