I am taking a java course in college and one of the homework assignments is to write a program that reads an integer between 0 and 100[inclusive], representing the amount of purchase. The issue I am having is the if-else statement. Every time I compile, it would say the less than equal sign is an illegal start of type. Can someone explain to me why that is and how I can fix it? Thanks in advance!
import java.util.Scanner;
public class RefundAmount {
public static void main(String [] args) {
Scanner scan = new Scanner (System.in);
int change;
int dollars, quarters, dimes, nickels, pennies;
System.out.println("Enter the purchase price [0-100]: ");
int price = scan.nextInt();
System.out.println("Enter the amount paid: ");
int paid = scan.nextInt();
change = price - paid;
dollars = (change / 100);
change = change % 100;
quarters = (change / 25);
change = change % 25;
dimes = (change / 10);
change = change % 10;
nickels = (change / 5);
change = change % 5;
pennies = change;
if (change >= 0 || <= 100){
System.out.print("Your change of " + purchase + " cents is given as:");
}else
System.out.println("Purchase must between 0 and 100 cents.");
System.out.println(" " + dollars + " dollars");
System.out.println(" " + quarters + " Quarters");
System.out.println(" " + dimes + " Dimes");
System.out.println(" " + nickels + " Nickels");
System.out.println(" " + pennies + " Pennies");
}
}
Aucun commentaire:
Enregistrer un commentaire