Write a java class (TeaParty.java) which has Static short numeric variables, Static SecureRandom object, Main method
- برمجة جافا
- 2021-12-03
- softwareEngineer
الأجوبة
import java.security.SecureRandom;
public class TeaParty{
public static short tea = 0;
public static short cake = 0;
public static SecureRandom object = new SecureRandom();
public static void main(String[] args){
prepareTea();
prepareCake();
printResult();
} // end main method
public static void prepareTea(){
tea = (short)object.nextInt(31);
} // end method
public static void prepareCake(){
cake = (short)(4 + object.nextInt(24));
}// end method
public static void printResult(){
System.out.println("I have put for you: "+ tea + " teacups and " + cake + " cake slices.");
if(tea < 5 || cake < 5)
System.out.println("oh no! Bad party!");
if(tea >= 5 && cake >= 5){
if(tea >= (cake*2) || cake >= (tea*2))
System.out.println("Wow! Great party!");
else
System.out.println("Good party! Yay!");
}
} // end method
} // end class
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال