Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How will you program using Java? oogle.com/c/MTQSOTYXNDgxODRa Survey Lab You Wil Description practios writing classes and then practice isaking arrays of objects from the class

How will you program using Java?

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

oogle.com/c/MTQSOTYXNDgxODRa Survey Lab You Wil Description practios writing classes and then practice isaking arrays of objects from the class your wrote write a prograr, that ear adr irister a survey ard tally its results. The prograr should begir by allowing the user to erter in the iter s to be surveyed, then it sbould allow the ueer to take the whet it has beom completed. The program needs to be monu driver thir gs like soft drirks, ears, NFL football tearr s, restaurarts, r usical survey using the survey items, and finally print a summary report of the survey Your survay progratm shouid be able to survey any topie indluding groups i Programming Notes Use the following classes ir your ir.pler ertation Driver this is the driver dlass for the progran Survey -this class is resporsible for adriristerirg the survey. It should get the iters to be surwned fror the user, take the survey, the prirta an v-ery report of the results. Surveytems-this cless represents one survwey nem. It includes the memi neme and the toeal mumber of wotes this iten received once the survey is comxplete Source Code 1. Copy the driver class below irto a file rar ed Driver ic class publie statie void ma: Page 14Q Sign m.google.com/c/MTQSOTYXNDgxODRa 1Copy the driver class below irto a file rar ed Driver public class Driver public static void main tstringil args) Survey survey new Survey); 2. Copy the class below into a file named Survey import java.util. public class Survey //-Instance Variables private SurveyIten[1 surveyItems: private int numItems private Scanner scan /Constructor public survey Methods /t precondition: none /f postcondition: prompts the user for the itens to be used Page 1 4 ogle.com/c/MTQ50TYXNDgxODRa nt in the survey. Once the items have been enter the method / invokes the takeSurvey method to administer the survey public void getSurveyItems // precondition: the survey items have been selected // postcondition: this method administers the survey. It provides a menu system so that users can cast their votes by selecting the number of the iten they wish to choose. This method is also responsible for tallying the results of the survey and invoking the sunmaryReport method to display the results public void takeSurvey) // precondition: the survey has been completed // postcondition: displays the results of the survey which includes the name of each item surveyed and the number of votes eceived by each item public void summaryReport ) 3. Copy the class below irto a file nar ed Surveyltem. public class SurveyItem Page 21 4Q+ /Instance Variable private String nane m.google.com/c/MTQ50TYxNDgxODRa document public class SurveyItem Instance Variables private String name private int count; /Constructor public SurveyIten (String n) nane n count 0 /Methods public sString getName () return name public int getcount () return count: public void vote() count++ Modifications Page 2 4 a + Survey Class MD google.com/c/MTQ50TYXNDgxODRa cument Modifications Survey Clas 1. Cor plete the constructor for the Suruey class. This r ethod should iritialize all instance variables ard irvoke the getSurvey tlethod so that the items to be surveyed can be retrieved from the user 2. Complete the method getSurveyltems according to the specifications outlined in its pre and postconditions. 3. Complete the method takeSurvey according to the specifications outlined in its pre and postconditions. 4 Complete the method suramaryReport according to the specifications outined in its pre and postoonditions Sample Run How many Items in this survey: 8 comD.Pepper e6Die Coke tern --> Die Dr. Pepper Page314 RMar com How many Items in this survey: 8 Iten 1 Coca Cola Item 2 - Pepsi Item 3 -> Dr.Pepper Item 4 > Sprite Item 5 -up Ttem 6-Diet Coke Item 7 --Diet Pepsi Item 8 Diet Dr. Pepper Survey select the number of the item you wish to ehoose: 1. Coca Cola 2. Pepsi 3. Dr. Pepper 4. Sprite 5. 7-Up 6. Diet Coke 7. Diet Pepsi 8. Diet Dr.Pepper s. IJuit survey Mate Selection: 3 Survey select the number of che item you wish ta choose: 1. Coca Cola 2. Pepsi 3. Dr. Pepper 4. Sprice 5. 1-Dp 6. Diet Coke 7. Diet Pepsi Page 34-+ le.com/c/MTO5OTYNDxODRa s. Diet Di. Papper 9, QJuit Survey Make Selection 1 Survey Select the number of the item you wish to choose 1. Coca Cala 2. Pepsi 3. Dr.Pepper 4. Sprite 5. 7-Up 6. Diet Cake 7. Diet Pepsi 8. Diet Dr.Pepper 9 [QIuit Survey Make Selection: 9 Survey Results Vates Item Coca Cola Pespi Dr. Pepper Sprite 7-Up Diet Coke Diet Pepsi Diet Dr. Pepper Press any key to continue Page 4 4 - comQ50TYxNDgxoDRa Make Selectin: 9 Survey Results Vetes Tcen Coca Cola Pespi Dr. Pepper Sprite 7-Up Diet Coke Diet Pepsi Die: Dr. Pepper Press any key ta coinue Close You will be able to write classes ard the r aripulatirg arrays of the objects appropriately Page 44

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions