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
HOW TO DISCONNECT A MONITOR FROM A SYSTEM UNIT
Sliva [168]

Answer: 1. Use the Windows key + P keyboard shortcut.

2. Using the “Project” flyout, select the PC screen only option.

3. Open Settings.

Click on Display.

Under the “Select and rearrange displays” section, select the monitor that you want to disconnect.

Select monitor on Windows 10

Under the “Multiple displays” section, use the drop-down menu and select the Disconnect this display option.

4 0
3 years ago
Jesse purchases a new smartphone and is immediately able to use it to send a photo over the Internet to a friend who lives in a
frez [133]

Answer:

D: A single direct connection is established between any two devices connected to the Internet.

Explanation:

The internet is a complex network system made of protocols, packets, and other things. For a network to be connected, it requires the use of multiple pathways. It is unnecessary for a single direct connection because of most of the networks in this real-world travel in multiple direct connections. For example, if you want to go to Brainly.com. It first needs your IP address and then the protocols like HTTP and TCP to send it. Networks are just like traffic. If one section or a part gets blocked, they go on a different path and reach their destination. It is the same here for networks. Networks go into multiple directions to get to their destination. Therefore, a single direct connection is not required or necessary to make it possible.  

8 0
3 years ago
Write a method called all Less that accepts two arrays of integers and returns true if each element in the first array is less t
GaryK [48]

Answer:

The program to this question can be given as:

Program:

#include<iostream> //header file

using namespace std; //using name space

bool allLess (int arr1[], int arr2[]) //defining method allLess  

{

int a,b; //define variable

a=  *(&arr1 + 1) - arr1; //hold length of arr1

b=  *(&arr2 + 1) - arr2; //hold length of arr2

if(a!=b) //checking condition  

{

return 1; //return value

}

for(int i=0; i<a; i++) //loop

{

if( arr1[i]>=arr2[i]) //checking condition

{

return 1; //return value

}

}

return 0; //return value

}

int main() //define main method.

{

   int arr1[]={1,2,3,4,5}; //define array arr1 and assign value.

   int arr2[]={4,5,6,7,8}; //define array arr2 and assign value.

   cout<< allLess(arr1,arr2); //function calling

   return 0;

}

Output:

1

Explanation:

The Explanation of the C++ language program can be given as follows:

  • In the above program firstly we include the header file. Then a method is defined that is "allLess" this method accepts two arrays that are "arr1 and arr2". This function returns a boolean value that is true or false.
  • Inside a function, we define a conditional statement and a loop in the if block we check the length of the arr1 array variable is not equal to arr2 array length. if this condition is true it will return false.
  • In the loop, we define another if block in this block we check that if arr1 array elements are grater then equal to arr2 array element if this condition is true it will return false. At the end of both if block and loop the function will return a value that is "true".
  • In the main method, we define two arrays and pass to the function and use (cout function) for print return value.
8 0
3 years ago
Write any two use of computer in school​
igomit [66]

Answer:

To solve mathmatical problem

To make questions paper

7 0
3 years ago
Consider the cement used for the foundation; the bricks and timber used for the walls; and the shingles used for the roof. All o
gavmur [86]
<span>Consider the cement used for the foundation; the bricks and timber used for the walls; and the shingles used for the roof. All of these are __________ in making the house.

A. Elements</span>
6 0
3 years ago
Other questions:
  • EXPLAINING A URL
    15·1 answer
  • Jason is computer professional who has access to sensitive information. He shares this information with another organization in
    8·1 answer
  • A user reports that she can't access the new server used in the accounting department. you check the problem and find out that h
    9·1 answer
  • What are the basic tools for coding HTML manually?
    10·2 answers
  • I need help!!!!
    13·2 answers
  • 24 POINTS!!! <br> Why are Sequences, Selection, and Iteration building blocks of algorithms?
    5·1 answer
  • How to enter date in a Date/Time field?​
    8·1 answer
  • Ok so I’m using a word document and towards the bottom of the page it stops me from moving my text box any further down even tho
    13·2 answers
  • A eclipse occurs at a full moon when the moon passes between earth and the sun
    8·1 answer
  • A for construct is a loop construct that processes a specified list of objects. As a result, it is executed as long as there are
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!