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
Of what is famous Ted Nelson?​
dsp73

Answer:

Nelson proposed a system where copying and linking any text excerpt, image or form was possible.

Explanation:

Ted Nelson is one of the theoretical pioneers of the world wide web who is best known for inventing the concept of hypertext and hypermedia in the 1960s. As one of the early theorists on how a networked world would work.

How I know:

I goggle it.

8 0
2 years ago
Can you please look through this code and see wants wrong with it? its in python
Ivanshal [37]
I’m confused what are you trying to ask? What is the python?
3 0
2 years ago
Which of the following code correctly registers a handler with a button btOK?a. btOK.setOnAction(e -&gt; System.out.println("Han
Bad White [126]

Answer:

The correct answer is C:

btOK.setOnAction((ActionEvent e) -> System.out.println("Handle the event"));

Explanation:

The button produces an action once clicked. The setOnAction method indicates what will happen when the button is clicked. Action Event is a type of event that gets processed by EventHandler, which provides the action to be performed by clicking the button (printing out "Handle the event").

4 0
3 years ago
Given a collection of n nuts and a collection of n bolts, arranged in an increasing order of size, give an O(n) time algorithm t
kari74 [83]

Answer:

See explaination

Explanation:

Keep two iterators, i (for nuts array) and j (for bolts array).

while(i < n and j < n) {

if nuts[i] == bolts[j] {

We have a case where sizes match, output/return

}

else if nuts[i] < bolts[j] {

this means that size of nut is smaller than that of bolt and we should go to the next bigger nut, i.e., i+=1

}

else {

this means that size of bolt is smaller than that of nut and we should go to the next bigger bolt, i.e., j+=1

}

}

Since we go to each index in both the array only once, the algorithm take O(n) time.

8 0
3 years ago
(100 points) why does file explorer look like this and how do I fix it? I'm not good with computers, and I kinda need help
Degger [83]

Go To View -> Navigation Pane -> Then Click Navigation Pane

7 0
3 years ago
Other questions:
  • To say the internet has helped democratize knowledge means that
    11·1 answer
  • A form of speech that is used to clarify, describe, demonstrate, and/or explain is referred to as _____.
    7·2 answers
  • Why does world of tanks keep downloading when I'm not even at the computer
    9·1 answer
  • Which are technical and visual demands that need to be considered when planning a project? Choose three answers
    10·1 answer
  • In 2009 to 2010, 1 in 10 social network users:
    10·1 answer
  • ​Suppose your computer network was compromised in a large scale virus attack last Thursday. Most of the data files got corrupted
    8·1 answer
  • According to which virtue do you need to secure information by limiting computer access to authorized personnel only?
    6·1 answer
  • What is a photographic print made from a negative image?
    7·1 answer
  • Which era marked a switch from agricultural practices to industrial practices?
    6·1 answer
  • What is the basic body structure of html.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!