Skip to content

Instantly share code, notes, and snippets.

@nikhilrajsingh
Created August 1, 2020 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikhilrajsingh/b1a424e7d7b3256cd274e9aab1ca8738 to your computer and use it in GitHub Desktop.
Save nikhilrajsingh/b1a424e7d7b3256cd274e9aab1ca8738 to your computer and use it in GitHub Desktop.
Lab4Task
/* 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