Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package PodgotovkaZaIzpit;
- import java.util.Scanner;
- public class ExcursionCalculator {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // Set initial variables
- int tourists = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- double pricePerTourist = 0;
- // Calculate pricePerTourist depending on season and tourist number
- if (season.equals("spring")) {
- if (tourists > 5)
- {
- pricePerTourist = 48;
- }
- else
- {
- pricePerTourist = 50;
- }
- }
- else if (season.equals("summer")) {
- if (tourists > 5)
- {
- pricePerTourist = 45;
- }
- else
- {
- pricePerTourist = 48.50;
- }
- }
- else if (season.equals("autumn")) {
- if (tourists > 5)
- {
- pricePerTourist = 49.50;
- }
- else
- {
- pricePerTourist = 60;
- }
- }
- else if (season.equals("winter")) {
- if (tourists > 5)
- {
- pricePerTourist = 85;
- }
- else
- {
- pricePerTourist = 86;
- }
- }
- double finalPrice = pricePerTourist * tourists;
- // Calculate discount/rise of finalPrice depending on the season
- if (season.equals("summer")) {
- finalPrice = finalPrice *.85;
- }
- else if (season.equals("winter")) {
- finalPrice =finalPrice * 1.08;
- }
- // Print out finalPrice (:F2 prints out 2 numbers after decimal point, use F1/F3/F4 for different outputs)
- System.out.printf("%f leva.", finalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement