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
Which of these statements is true?
expeople1 [14]

Answer:

D. Cognitive systems can learn from their successes and failures

Explanation:

Cognitive System is a term used in Computer Science to describe an advanced computer in which it was built to think and behave like humans. In other words, it is a form of artificial intelligence, which has the ability to assess activities before taking them.

Hence, in this case, the right answer is "Cognitive systems can learn from their successes and failures," because this is an attribute of human being, in which cognitive computing is created to behave or have human reasoning.

7 0
3 years ago
Which port-authentication network access control standard forces devices to go through a full authentication, authorization, and
DiKsa [7]

802.1X is the port-authentication network access control standard that forces devices to go through a full authentication, authorization, and accounting (AAA) process to get anywhere past the interface on a gateway system. This standard is defined by the IEEE and defines a client and server-based access controls.In a wireless LAN with 802.1X, a user (known as the supplicant) requests access to an access point (known as the authenticator).

5 0
3 years ago
Explain how buyers and sellers factor into setting the stock price for a company’s shares.
Kitty [74]

Answer:

The stock price of a company share depends upon the supply and demand. And demand is more if more buyers have positive intent towards the company services or end product. Also if the services and end product are trending, the more buyers buy them, and hence demand increases, and hence the value of the company shares, and hence the stock price.  

Explanation:

The stock price of a company share depends upon the supply and demand. And demand is more if more buyers have positive intent towards the company services or end product. Also if the services and end product are trending, the more buyers buy them, and hence demand increases, and hence the value of the company shares, and hence the stock price.  

Thus as mentioned above, the stock price is down when less buyers shows the intent to buy, and the demand hence is low. The sellers show interest only if demand is high, and sometimes if company sells for less amount and gives more profit margin.

6 0
3 years ago
The _____ feature enables you to represent text as colorful visuals.
Radda [10]

Answer:

complex formatting feature enables you to represent text as colorful

visuals.

mark as brainliest

4 0
2 years ago
Out put of Print (3**2*2)
expeople1 [14]

Answer:

18

Explanation:

please mark me as brainliest

4 0
2 years ago
Read 2 more answers
Other questions:
  • What is the outlined area called?
    6·1 answer
  • An _________ is a phrase formed from the first letters of words in a set phrase or series of words a. Acronymic sentence c. Basi
    7·2 answers
  • When you first open office calc, the most recently saved spreadsheet opens up. A) true B) false
    14·1 answer
  • Explain why blocking ping (ICMP echo request) packets at an organization's edge router is not an effective defense against ping
    11·1 answer
  • ____ is an object-oriented programming language from Sun Microsystems which allows small programs called applets to be embedded
    13·1 answer
  • Which of the following STEM discoverers is known for creating complex computational physics to develop computer models to simula
    7·1 answer
  • An Internet Service Provider (ISP) is a company that builds the routers and wired connections that allow individuals to access t
    12·2 answers
  • Before you give your presentation to an audience, you should make sure that your ideas are organized in a clear and meaningful w
    8·2 answers
  • What is a web browser​
    9·1 answer
  • 2023 murano’s available intelligent awd adjusts the ________ to help maintain cornering control.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!