Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is the current code in java. I keep getting a duplicate class error. I cant seem to find the duplicate. Is there something I

Here is the current code in java.

I keep getting a duplicate class error. I cant seem to find the duplicate. Is there something I am doing wrong

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package week_3;

/** * * @author j0nny */ public class PRG215_Week_3. { @SuppressWarnings({"empty-statement", "UnusedAssignment"}) public static void main(String[] args) {

//Create eh items names and item costs arraus String[] itemNames = {"Tennis Shoes", "Shirts", "Coats", "Belts", "Pants"}; double[] itemCosts = {45.89, 25.55, 89.99, 15.00, 25.99}; //variables to for the financial calculations double totalAmount = 0.0; double taxRate = 0.081; //Discounts for large purchases double discountRate = 0.025; //2.5% double amountToQualifyForDiscount = 100; double discountAmount = 0; //Display items for sale on the console System.out.println("The following clothing items are available for purchase."); for(int i = 0; i < itemNames.length; i++) { //Display each item in the array System.out.println(" " + (i + 1) + "." + itemNames[i] + "for$" + itemCost[i] + "each"); } System.out.println(""); //Create a keyboard input object Scanner keyboard = new Scanner(system.in); //Display on the console - ask for the customer's name System.out.print("Please enter your name:"); //Get the customer name from the keyboard and store it in the String object "customerName" String customerName = keyboard.next(); System.out.println(""); //Display the customer's name and provide instructions System.out.println("Ok," + customerName + ", please enter the product ID (the number to the left of the item name that you wish to purchase. Enter 0 when you are finished."); //Loop until the user enters 0 @SuppressWarnings("UnusedAssignment") int itemID; //Set the condition to 0 itemID = 0; int itemCounter = 1; //No longer the loop condition counter, now used for display do // We're using a different type of loop structure now { //Prompt the user System.out.print("Plese enter item ID number " + (itemCounter) + "(enter 0 to exit.):"); itemID = keyboard.nextInt(); //If the user has not entered 0, then add to the total if(itemID > 0) { //Add to the total totalAmount = totalAmount + itemCosts[itemID + 1]; //Increment the item display counter itemCounter ++; } } while(itemID != 0); //Check if exit condition has been met //The loop is complete, calculate the discount and taxes and then display the results if(totalAmount >= amountToQualifyForDiscount) { disountAmount = totalAmount * discountRate; } else { discountAmount = 0; } //Calculate the taxes double taxAmount = (totalAmount - discountAmount) * taxRate; //Display the results System.out.println(""); System.out.println("You selected" + itemCounter + "items to purchase."); System.out.println("Your sales total $" + totalAmount); System.out.println("Your discount amount is $" + discountAmount); System.out.println("Your sales tax is $" + taxAmount); System.out.println("The total amount due is $" + (totalAmount - discountAmount + taxAmount)); System.out.println(""); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions