Last active
March 20, 2021 22:15
-
-
Save farithadnan/59621378f8d93bed276380c4aed177d1 to your computer and use it in GitHub Desktop.
Temperature scanner using Java. Using condition to determine the different between suitable and bad temperature.
This file contains hidden or 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
| import java.util.Scanner; | |
| import java.lang.String; | |
| public class Covid | |
| { | |
| public static void main (String[] args) | |
| { | |
| double temperature = 0.0; | |
| String[] name = new String[20]; | |
| int[]num = new int[20]; | |
| int nameCount = 0; | |
| int numCount = 0; | |
| int validCount = 0; | |
| int loop = 1; | |
| char choice; | |
| char detail; | |
| Scanner scan = new Scanner (System.in); | |
| Scanner word = new Scanner (System.in); | |
| do | |
| { | |
| System.out.print("\nPlease enter temperature:"); | |
| temperature = scan.nextDouble(); | |
| System.out.println("Your temperature is " + temperature); | |
| if((temperature >= 36.0) && (temperature <= 37.5)) | |
| { | |
| while ((temperature >= 36.0 )&& (temperature <= 37.5)) | |
| { | |
| System.out.println("You may enter the premise. Enjoy the services provided in our premise."); | |
| System.out.print("\nPlease enter your name : "); | |
| name[nameCount] = word.nextLine(); | |
| System.out.print("\n"); | |
| System.out.print("Please enter your phone number : "); | |
| num[numCount] = scan.nextInt(); | |
| System.out.print("\n"); | |
| temperature /= 100; | |
| validCount++; | |
| ++nameCount; | |
| ++numCount; | |
| } | |
| } | |
| else if(temperature > 37.5) | |
| { | |
| System.out.println("You have a fever. You are not allowed to enter the premise."); | |
| } | |
| else if(temperature < 36.0) | |
| { | |
| System.out.println("You have entered invalid temperature. Please re-check your temperature"); | |
| } | |
| else | |
| { | |
| System.out.println("Error!"); | |
| } | |
| System.out.print("\nReady for next input? (y/Y) : "); | |
| choice = scan.next().charAt(0); | |
| }while((choice == 'y' || choice == 'Y')); | |
| System.out.println("\nThe number of valid visitors to your premise today is : " + validCount); | |
| System.out.print("\nWould you like to see the details of your customer for today? (y/Y) :"); | |
| detail = scan.next().charAt(0); | |
| if((detail == 'y') || (detail =='Y')) | |
| { | |
| System.out.println("\nNo" + " " + "Name"+ " " + "Phone Number"); | |
| for(int i = 0; i < validCount; i++) | |
| { | |
| System.out.println((loop++) + " " + name[i]+" " + num[i]); | |
| } | |
| System.out.println("\nThank you for using our service. Goodbye!"); | |
| } | |
| else | |
| { | |
| System.out.println("Thank you for using our service. Goodbye!"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment