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
There are some network modeling tools that can ________ the existing network.
lesya [120]
<span>There are some network modeling tools that can scan the existing network.</span>
4 0
3 years ago
Read 2 more answers
Write a SELECT statement that returns one row for each customer that has orders with these columns:
d1i1m1o1n [39]

Answer:

SELECT email_address,

SUM(item_price * Quantity) AS item_price_total,

SUM(discount_amount * Quantity) AS discount_amount_total

FROM Customers c

JOIN Orders o ON c.CustomerID = o.CustomerID

JOIN Order_Items oi ON o.OrderID = oi.OrderID

GROUP BY email_address

ORDER BY item_price_total DESC

Explanation:

In this SQL statement the SELECT statement selects the following columns:

email_address

item_price

Quantity

discount_amount

There are two tables Customers and Order_Items

SUM aggregate function is used to add the values of the product of the columns discount_amount and Quantity. It is also used to get the sum of the product of two columns discount_amount and Quantity.

A new temporary column named item_price_total is used to name the sum of the product of two columns discount_amount and Quantity using AS which is ALIAS and it is used to give a name to some columns or a table.

Similarly discount_amount_total name is given to the column which calculate the sum of the product of two columns i.e. discount_amount and Quantity.

JOIN is used here to join the columns from the tables Order_items and Customers.

GROUP BY is used to group the result of rows and is used with functions like SUM. Here the rows are grouped by the email address.

ORDER BY is used to order the result. Here the result is ordered by item_price_total in descending  order.

This SELECT statement can also be written as following:

SELECT c.email_address,

SUM(o.item_price * o.Quantity),

SUM(o.discount_amount * o.quantity)

FROM customer c

JOIN Order_Items o ON o.id = c.id

GROUP BY c.email_address

7 0
3 years ago
When media is used to communicate with a very large audience, it is referred to as media.
Sophie [7]

Answer:

mass media

Explanation:

6 0
3 years ago
Read 2 more answers
What will be the color if today is Saturday?
Dennis_Churaev [7]

Answer:

I would say D but I am not for sure

6 0
3 years ago
A database is used instead of a spreadsheet when ________.
Ierofanga [76]

Answer:

C. Lists involve data with multiple themes

Explanation:

<em>First of all, it will be beneficial to explain all the concepts involved.</em>

<em />

A spreadsheet is an electronic ledger in which data is arranged in rows and columns of a grid and can be manipulated and used in calculations.

A database can be defined as a structured set of data held in a computer, especially one that is accessible in various ways.

A theme in data storage refers to the subject matter or topic  that categorizes various data sets.

A spreadsheet can be used to store and analyse simple data sets as shown in the options A, B and D. However for option C, a database must be used if it needs to be done accurately.

A data base is more robust than a spreadsheet and can accommodate a lot more diversities in the data sets.

Spreadsheets are built to simplify data analysis, and have their candid limitations - they cannot assure data integrity or consistency when dealing with data of various subject matters.

Lists that involve data with multiple themes can be easily handled with data bases, because data bases specialize in collecting raw data in a tabular form which cannot be formatted. This helps sort out the data into their various themes.

The tables on a database can be programmed to accept a particular theme of data, and nothing else. however, this cannot be done with spreadsheets, as the cells accept the data first before it is formatted to the data type it is. Thus databases help ensure consistency and integrity of the data when dealing with data of multiple themes

5 0
3 years ago
Other questions:
  • Which shortcut key combination will move the cursor to the beginning of the line
    10·1 answer
  • What is a Windows feature that allows you to temporarily store text?
    5·1 answer
  • The protocol that enables computers on the Internet to communicate with one another is called _____.
    10·2 answers
  • Jim wants to buy a car, but he’ll probably only need it for a couple of years. He has a short commute to work, so he won’t be pu
    5·1 answer
  • When you insert a photo into a document, its placed at the ​
    13·2 answers
  • Complete the procedure for pasting content from a Word document in a message by selecting the correct term from
    7·2 answers
  • Why doesn't brainly give me 15 questions a day
    11·2 answers
  • A network consists of 75 workstations and three servers. The workstations are currently connected to the network with 100 Mbps s
    12·1 answer
  • 3 uses of a computer ​
    12·2 answers
  • Question 1 of 10
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!