Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class App {
- public static void main(String[] args) throws Exception {
- Scanner s = new Scanner(System.in);
- double price = 2.00;
- System.out.print("Type: ");
- String type = s.next();
- if (!type.equalsIgnoreCase("milk") && !type.equalsIgnoreCase("dark")) {
- System.out.println("You can choose between milk and dark.");
- return;
- }else if (type.equalsIgnoreCase("dark")) {
- price += 0.4;
- }
- System.out.print("Weight: ");
- int weight = s.nextInt();
- if (weight < 50) {
- System.out.println("This chocolate is too small.");
- return;
- } else if (weight > 250) {
- System.out.println("This chocolate is too large.");
- return;
- }
- price += 0.015 * weight;
- System.out.printf("This %s chocolate has weight %d g and will cost you %.2f leva.\n", type, weight, price);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement