Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with an error This is the following code i used: import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc

Help with an error

image text in transcribed

This is the following code i used:

import java.util.Scanner;

public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in);// creates scanner object to take input

System.out.print("Enter number of packages purchased: "); // prompts user to input of no. of packages int quantity = sc.nextInt();

double totalAmount = 0, discount = 0; int regularPrice = 99; // value given in question

if(quantity>10){ if(quantity

System.out.printf("Your discount is: $%.2f ",discount); // prints the discount totalAmount = quantity*99 - discount; // calculates total amount after deducting discount System.out.printf("Your total is: $%.2f ", totalAmount); // prints total amount } }

I keep on getting this error:

"SoftwareSales.java:3: error: class Main is public, should be declared in a file named Main.java

public class Main {

^

1 error

"

A software company sells a package at the regular price of $99. Quantity discounts are given according to the following table: Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount. Hint: To calculate 20% of a value N, you can use the formula 0.2N. Look carefully at the following sample run of the program. In particular, notice the wording of the messages and the placement of spaces and colons. Your program's output must match this. Sample Run Enter number of packages purchased: 50d Your discount is: $1980.00 Your total is: $2970.00

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 Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

Working with other project stakeholders for support.

Answered: 1 week ago

Question

Knowledge of project management (PMI) teachings

Answered: 1 week ago