Created
August 1, 2020 15:19
-
-
Save nikhilrajsingh/b1a424e7d7b3256cd274e9aab1ca8738 to your computer and use it in GitHub Desktop.
Lab4Task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Created by IntelliJ IDEA. | |
* Author: Nikhil Raj Singh | |
* Date: 1/08/20 | |
* Time: 8:10 pm | |
* File: Lab4Task.java | |
*/ | |
package course.lab.labTasks.lab4; | |
import java.util.Scanner; | |
public class Lab4Task { | |
// This is the total number of participants allowed in the conference. | |
// DO NOT CHANGE/REMOVE THIS CODE. | |
private static final byte TOTAL_PARTICIPANTS = 100; | |
// This method will sell the ticket to the participant. | |
// DO NOT CHANGE/REMOVE THIS CODE. | |
private static void sellTicket(String participantName) { | |
String message = "Congratulations, " + participantName + ". " + | |
"See you at the conference!"; | |
System.out.println(message); | |
} | |
public static void main(String[] args) { | |
byte numberOfTicketsSold = 0; | |
while (numberOfTicketsSold <= TOTAL_PARTICIPANTS) { | |
int totalTicketsLeft = TOTAL_PARTICIPANTS - numberOfTicketsSold; | |
System.out.println("Total Tickets Left = "+totalTicketsLeft); | |
System.out.println("Please Input Your Name "); | |
Scanner scanner = new Scanner(System.in); | |
String name =scanner.next(); | |
sellTicket(name); | |
numberOfTicketsSold ++; | |
if (numberOfTicketsSold==TOTAL_PARTICIPANTS) { | |
System.out.println("Sorry, The tickets are sould-out!"); | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment