Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How will you program using Java? TYANDgxODRa bar. Import bookmarks now.. Survey Lab You will practice writing classes and then practice making arrays of objects

image text in transcribed

How will you program using Java?

image text in transcribed

image text in transcribed

image text in transcribed

TYANDgxODRa bar. Import bookmarks now.. Survey Lab You will practice writing classes and then practice making arrays of objects from the class your wrote. Description White a prograr, that ear adr irister a survey ard tally it results.,The prograr should begir by allowing the user to erter in the iter s he survey using the survey items, and finally print a summary report of the survey should be able to survey any topic including to be surveyed, then it should allow the user to taket when it has been completed. The program needs to be menu driven. Your survey program s thirgs like soft drirks, cars, NFT football tear s, restaurarts, r usical groups Programming Notes Use the following classes ir your ir plenertatior Driver-this is the driver class for the prograr Survey- this class is resporsible for adr.iristerirg the survey. It should get the iterrs to be surveyed prirt a sur tary report of the results. from the user, take the survey, the Surveyltems this class represents one survey item. It includes the items name and the total number of votes this item received once the survey is complete. Source Code L. Copy the driver class below irto a file rar ed Driver public class Driver public stetic void main (Stringl args) Survey survey hen survey o 2. Copy the class below into a file named Survey import java util. public cless 5urvey Instance Variables private SurveyItemtl surveyItems PrivaL int num l tema i Constructor Page 1 I4Q + public Survey arks bar. Import bookmarks now.. /-Instance Variables private SurveyItem[1 surveyItems; private int numItems; private Scanner scan; //- Constructor public Survey() //Methods // precondition: none // postcondition: prompts the user for the items to be used // 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 / postocanditian: this methad administers the survey. It provides a menu aystem so that users can cast their votes by selecting the number of the item they wish to choose. This method is also responsible for tallying the results of the survey and invoking the summaryReport 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 received by each item public void summaryReport (0 3. Copy the class below rto a file rared Survey Item public class SurveyTtem ence (AP) Perio + MTQSOTYANDgxODRa okmarks bar. Import bookmarks now... includes /I the name of each item surveyed and the number of votes public void sunmaryReport O received by each item. 3. Copy the class below irto a file nar ed Surveyltem public class Surveyitem Instance Variables private String name; private int count: Constructor public SurveyItem (String n) nanen: count0 Methods public String getName ) return name public int getcount ) return count: public void vote( count++i Modifications Survey Class 1. Cor plete the constructor for the Suruey class. This n.ethod ahould iritialize all instance variables and irvoke the getSurvey method so that the items to be surveyed can be retrieved from the user Complete uhe method getSurveyItems according to the specifications outlined in its pre and postconditions. eros YANDgxODRa ar. Import bookmarks now... count++ Modifications 1. Cor plete the constructor for the Suruey class. This r ethod should iritialize all instance variables and irvoke the getSurvey method so that the items to be surveyed can be retrieved from the user 2. Complete the method getSurveyItems 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 outlined in its pre and postconditions. Sample Run Survey Items How many Items in this survey: 8 Item 1Coca Cola Item 2 -- Pepsi Item 3DE. Pepper Item 4 -Sprite Item 57-up Item 6Diet Coke Item 7 --> Diet Pepsi Item 8 Diet Dr. Pepper Survey Select the number of the item you wish to choose: 1. Coca Cola 2. Pepsi 3. Dr. Pepper 4 Sprite 5 7-Up 6. Diet Coke 7 Diet Pepai

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

Recommended Textbook for

More Books

Students also viewed these Databases questions