-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
35 lines (30 loc) · 1.37 KB
/
Main.java
File metadata and controls
35 lines (30 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Author: Emily Flores
// Purpose: Simulates concert admission with data validation & ticket prices
// Date Modified: 05/15/23
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double ticketPrice = 15.99;
System.out.println("Welcome to the Concert Admissions!");
System.out.print("Enter your name: ");
String userName = scanner.nextLine();
System.out.print("Enter your age: ");
int userAge = scanner.nextInt();
if (userAge >= 13){
System.out.println("Congrats! " + userName + " you meet the requirements.");
System.out.print("How many tickets would you like to purchase? ");
int ticketsPurchased = scanner.nextInt();
if (ticketsPurchased >= 3){
double discountedPrice = (ticketsPurchased * ticketPrice)-(ticketsPurchased * 0.5);
System.out.printf("%s%.2f\n","Your total is: $", + discountedPrice);
} else{
double regularPrice = ticketsPurchased * ticketPrice;
System.out.printf("%s%.2f\n","Your total is: $", + regularPrice);
}
System.out.println("Enjoy the concert!");
} else{
System.out.println("Sorry, " + userName + " you do not meet the requirements.");
}
}
}