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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started