Skip to content

Instantly share code, notes, and snippets.

@JorgeOlvera
Created November 6, 2013 14:57
Show Gist options
  • Save JorgeOlvera/7337374 to your computer and use it in GitHub Desktop.
Save JorgeOlvera/7337374 to your computer and use it in GitHub Desktop.
/*3. Shirts are on sale for $10 each if more than three are purchased and $12 each
otherwise. Write a program (save it as Shirts) that prompts the user for the number of
shirts purchased and display on screen the total cost according to the mentioned criteria.
*/
import java.util.Scanner;
import java.io.*;
public class Shirts {
public static void main(String[] args) {
String shirts;
Scanner input = new Scanner(System.in);
System.out.println("Please specify the amount of shirts you want to buy");
shirts = input.nextLine();
if (shirts < 0){
System.out.println("You cannot purchase a negative amount of shirts. Go home, you're drunk");
}
else if (shirts = 0) {
System.out.println("Have a nice day")
}
else if (shirts >= 1 AND shirts <=3) {
System.out.println("The price for" + shirts + "of shirts is " + shirts * 12)
}
else (shirts > 3) {
System.out.println("You're in for a discount! Your price is" + shirts *10)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment