Question: import java.util.*; import java.lang.*; import java.io.*; class Main { public static void main (String[] args) throws java.lang.Exception { // Initializing Scanner object to read the

import java.util.*; import java.lang.*; import java.io.*;

class Main { public static void main (String[] args) throws java.lang.Exception { // Initializing Scanner object to read the input Scanner obj = new Scanner(System.in); //Initializing variables total and numberOfItems double total = 0; int numberOfItems = 5; //These arrays store the item names and their respective prices String items[] = new String[numberOfItems]; Double price[] = new Double[numberOfItems]; //Iteraing in the loop for(int i=1;i<=numberOfItems;i++){ //Reading the item name and the price of each Item items[i-1] = obj.next(); price[i-1] = obj.nextDouble(); //Adding the price to total total = total + price[i-1]; } //printing the Items and total for(int i=1;i<=numberOfItems;i++){ System.out.println(items[i-1]+" = $"+price[i-1]); } System.out.println("Total is "+total); } }

You should have had multiple java files, with the main file being the cashier class. You seem to have part of the logic in your file, but it is not complete. The naming convention is incorrect as well as the folder name and packaging.

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!