Question: th Question 4 (10 points): Spreadsheets can be stored in a format called Comma Separated Values (CSV), which are text files with data separated by

thth Question 4 (10 points): Spreadsheets can be stored in a format

Question 4 (10 points): Spreadsheets can be stored in a format called Comma Separated Values (CSV), which are text files with data separated by commas. Consider the spreadsheet below: Book Cost Number Hamlet 24.95 10 King Lear 18.42 13 If this data were stored in a CSV file, it would appear as follows: Book , Cost, Number Hamlet , 24.95, 10 King Lear , 18.42, 13 Suppose this information is typed into a computer. Write a code fragment to read the data with the Scanner constructed below. Calculate the total cost (24.95 + 18.42) and total number of books (10 + 13) and store these values in the variables totalCost and totalNumber. Scanner keyboard = new Scanner(System.in); double totalCost = 0; int totalNumber = 0; // Write your code below using only these variables. Your code // should not contain literal values. For instance, do not calculate // the total cost with the statement "totalCost = 24.95 + 18.42". // Instead, use the Scanner to read the values from the keyboard. This is a java question intro class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!