Answer to Question #219718 in Java | JSP | JSF for krish

Question #219718

Josh is conducting an event at every weekend. He will distribute the cold drink and snacks to participants. At end of each event, he will check the event’s outcome as integer i.e., 0=bad, 1=good, or 2=great.

• An event is Good (1) if both cold drink and snacks are at least 10 distributed to participants.

• If either cold drink or snacks is at least double the amount of another one, the event is Great (2).

• If either cold drink or snacks is less than 10 the event is always Bad (0).

Write java program to display an event result as either Great, Good or Bad.



1
Expert's answer
2021-07-22T18:46:59-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		
		int drink, snacks;
		System.out.println("Enter number of cold drinks: ");
		Scanner in =new Scanner(System.in);
		drink=in.nextInt();
		System.out.println("Enter number of snacks: ");
		snacks=in.nextInt();
		
		int outcome;
		if (drink>=10 && snacks>=10){
		    outcome=1;
		    System.out.println("The result of the event is good");
		}
		else if (drink>=(2*snacks) || snacks>=(2*drink)){
		    outcome=2;
		    System.out.println("The result of the event is great");
		}
		    
		else if (drink<10 || snacks<10){
		    outcome=0;
		    System.out.println("The result of the event is bad");
		}
		    
		 
		
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS