Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In java please, Write a program called Survey that tallies the results for a bev

ID: 3724553 • Letter: I

Question

In java please,

Write a program called Survey that tallies the results for a beverage survey. The program should prompt the user to enter the beverage number chosen by a survey participant until the user enters alue -1. Once that value has been entered, display the survey results (i.e., the number of times each beverage was chosen). You can assume users enter a valid choice when prompted You will need to create several variables to keep track of the number of times each beverage is chosen. Your output should look similar to the example below. Note: feel free to use beverages of your own choosing. Example 1: 1.Coffee 2.Milk 3.Red Bull 4.Water Please enter the person's choice: 1 1.Coffee 2.Milk 3.Red Bull 4.Water Please enter the person's choice: 3 1.Coffee 2.Milk 3.Red Bull 4. Water Please enter the person's choice: 1 1.Coffee 2.Milk 3.Red Bull 4.Water Please enter the person's choice: 4 1.Coffee 2.Milk 3.Red Bul1 4.Water Please enter the person's choice: -1 Survey Results Coffee 2 Milk 0 Red Bull1 Water 1

Explanation / Answer

As per your requirement the below one is solution please follow it

Source Code:-
---------------------------
package com.venkanna;

import java.util.Scanner;

public class Servey {

public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int option=0,Coffee=0,Milk=0,red_bull=0,Water=0;
try{
do
{
System.out.println("1.Coffe 2.Milk 3.Red_Bull 4. Water");
System.out.println("Please Enter the Person's Choice");
option=sc.nextInt();
switch(option)
{
case 1:
Coffee++;
break;
case 2:
Milk++;
break;
case 3:
red_bull++;
break;
case 4:
Water++;
break;
case -1:
break;
default:
System.out.println("Wrong Option");
}
}while(option!=-1);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
System.out.println("Servey Results");
System.out.println("Coffee "+Coffee+" Milk "+Milk+" red_bull "+red_bull+" Water "+Water);
}

}


Sample Output:-
====================

1.Coffe 2.Milk 3.Red_Bull 4. Water
Please Enter the Person's Choice
1
1.Coffe 2.Milk 3.Red_Bull 4. Water
Please Enter the Person's Choice
2
1.Coffe 2.Milk 3.Red_Bull 4. Water
Please Enter the Person's Choice
4
1.Coffe 2.Milk 3.Red_Bull 4. Water
Please Enter the Person's Choice
1
1.Coffe 2.Milk 3.Red_Bull 4. Water
Please Enter the Person's Choice
2
1.Coffe 2.Milk 3.Red_Bull 4. Water
Please Enter the Person's Choice
4
1.Coffe 2.Milk 3.Red_Bull 4. Water
Please Enter the Person's Choice
-1
Servey Results
Coffee 2
Milk 2
red_bull 0
Water 2

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote