Question: 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

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
Get step-by-step solutions from verified subject matter experts
