Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Below is a Unified Modelling Language (UML) diagram of an election class. Election - candidate: String -numVotes: int < >+ Election () < >+

Below is a Unified Modelling Language (UML) diagram of an election class. Election - candidate: String

Below is a Unified Modelling Language (UML) diagram of an election class. Election - candidate: String -numVotes: int < >+ Election () < >+ Election (nm: String, nVotes: int) + setCandidate( nm: String) + setNum Votes(): int + toString(): String Using your knowledge of classes, arrays, and array list, write the Java code for the UML above in NetBeans. [7 marks] Write the Java code for the main method in a class called TestElection to do the following: a) Declare an array to store objects of the class defined by the UML above. Use a method from the JOptionPane class to request the length of the array from the user. [3 marks] b) Use a method from the JOptionPane class to request values from the user to initialize the instance variables of Election objects and assign these objects to the array. The array must be filled.

Step by Step Solution

5.00 Ratings (1 Votes)

There are 3 Steps involved in it

Step: 1

Here is the Java code for the Election class based on the provided UML diagram import javaxswingJOpt... blur-text-image

Get Instant Access with AI-Powered 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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

9780134462035

More Books

Students also viewed these Programming questions