Advertisement
KristianIvanov00

Untitled

Nov 24th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class App {
  4. public static void main(String[] args) throws Exception {
  5. Scanner s = new Scanner(System.in);
  6.  
  7. double price = 2.00;
  8. System.out.print("Type: ");
  9. String type = s.next();
  10.  
  11. if (!type.equalsIgnoreCase("milk") && !type.equalsIgnoreCase("dark")) {
  12. System.out.println("You can choose between milk and dark.");
  13. return;
  14. }else if (type.equalsIgnoreCase("dark")) {
  15. price += 0.4;
  16. }
  17.  
  18. System.out.print("Weight: ");
  19. int weight = s.nextInt();
  20.  
  21. if (weight < 50) {
  22. System.out.println("This chocolate is too small.");
  23. return;
  24. } else if (weight > 250) {
  25. System.out.println("This chocolate is too large.");
  26. return;
  27. }
  28.  
  29. price += 0.015 * weight;
  30.  
  31. System.out.printf("This %s chocolate has weight %d g and will cost you %.2f leva.\n", type, weight, price);
  32. }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement