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
Size of a MAN can range from ​
Dovator [93]

Answer:

According to the latest CDC stats, these are the average heights for U.S. adult men based on age:

Ages 20 to 39: 176.1 centimeters

Ages 40 to 59: 175.8 centimeters

Age 60 and older: 173.4 centimeters

6 0
3 years ago
When you first log into linux, what is the current working directory?
mina [271]
This will depend on what the user has set the default working directory to. In order to check for yourself what your default working directory is inside linux, simply log in, click the start button>Click System Tools>LXTerminal. Once in the terminal, you can check your current working directory by typing in "pwd" without the quotation marks. Then, hit enter on your keyboard and the terminal will print your current working directory. I hope this has helped you.
6 0
3 years ago
Based on the relational model, create the database metadata as part the physical designphase.b)from the metadata, write the sql
galben [10]
<span>Which is not a component of a database that describes how data is stored?</span>
5 0
3 years ago
JAVA...Write a statement that calls the recursive method backwardsAlphabet() with parameter startingLetter.
scoray [572]

Answer:

RecursiveCalls.backwardsAlphabet(startingLetter);

Explanation:

The statement that is needed is a single-line statement. Since the class RecursiveCalls is already in the same file we can simply use that class and call its function without making a new class object. Once we call that class' function we simply pass the variable startingLetter (which is already provided) as the sole parameter for the function in order for it to run and use the letter 'z' as the starting point.

       RecursiveCalls.backwardsAlphabet(startingLetter);

3 0
3 years ago
After you set a goal or purpose for your Web site, what is the next step to designing your​ pages​?
Hatshy [7]

Answer:

et your goal.

Choose a website builder.

Define your layout.

Claim your domain name.

Gather your content.

Add the right pages.

Design your website elements.

Pick the professional tools you need.

Explanation:

7 0
2 years ago
Other questions:
  • If you are going to attach more than 15 devices to your wireless network, you should make sure your router supports which standa
    14·1 answer
  • High productivity will typically get you positive attention and feedback when you are on a job.
    7·1 answer
  • What is the internet?
    5·2 answers
  • zeroIt is a function that takes one argument and returns no value. The function stores the value 0 back into the parameter. x is
    8·1 answer
  • Think about what you have learned about work ethic. In a paragraph of no less than 125 words, explain why employers prefer to hi
    15·1 answer
  • Suppose that a server sends four packets of audio data, in 15 seconds each. The first is sent by the server exactly at noon (12:
    14·1 answer
  • What are some signs that could help you determine that a date and time was inserted as a special object instead of
    14·1 answer
  • In what ways are computers being used to improve our quality of life
    15·1 answer
  • 19) If you want to find your lowest paid, full time employee (with "FT" in column B and each employee's salary found in column C
    8·2 answers
  • There is a development team delivering a new software package with agile and devops frameworks. in one of the releases, the auto
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!