Advertisement
did0sh

Problem08. Calories Counter

Sep 24th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. * Created by user on 23.9.2017 г..
  5. */
  6. public class p08_CaoriesCounter {
  7. public static void main(String[] args) {
  8. Scanner scan = new Scanner(System.in);
  9.  
  10. int n = Integer.parseInt(scan.nextLine());
  11. int calories = 0;
  12.  
  13. for (int i = 0; i < n ; i++) {
  14. String ingredient = scan.nextLine().toLowerCase();
  15.  
  16. if (ingredient.equals("cheese")){
  17. calories += 500;
  18. } else if (ingredient.equals("tomato sauce")){
  19. calories += 150;
  20. } else if (ingredient.equals("salami")){
  21. calories += 600;
  22. } else if (ingredient.equals("pepper")){
  23. calories += 50;
  24. }
  25. }
  26.  
  27. System.out.printf("Total calories: %d", calories);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement