Designing an electronic voting machine is a challenging task. You are asked to implement a very simplified voting machine class with the following specification. A voting machine has a list of candidates and the following methods: a) addCandidate(String name) /* Add a candidate with the name to the list */ b) castVote(String name) /* Cast a vote to the candidate with the name */ c) printResults() /* Print out the number of votes each candidate has received. The order does not matter */
Q: Write a python program that takes a list from a user containing both positive and negative numbers.…
A: The Python code is given below with output screenshots All the Best ?
Q: Write a java program ( One class with a main method ) to do the following : 1. Prompt the user to…
A: Actually, java is a object oriented programming language. It is a platform independent. It is a high…
Q: Write a client program that loops around getting two fractions from the user,output their sum, and…
A: Program code: Fraction.java //Define the class Fractionpublic class Fraction { // declaring instance…
Q: Create a Python program that gets 2 inputs from the user. The first input is a series of names…
A: pop is used to remove an element at specified index append is used to insert element at end
Q: Write a Java program to do the following task: Create an integer array of size 15. Input the values…
A: PROGRAM CODE: import java.util.*; // import utility package for javapublic class Main{…
Q: Implement a program in C++ that does the following: 1. Displays a Menu (using a do...while loop)…
A: The ask is to write a C++ program doing the following: - display a menu to take user input - add an…
Q: reads a Java program and makes a list of all the user-defined identifiers.
A: Algorithm: Create a list of reserved words. Iterate through the document, line by line. Extract…
Q: We are going to write a python program that uses 2 lists: A list to hold the primary colors [Red,…
A: a python program that uses 2 lists: A list to hold the primary colors [Red, Yellow, Blue], or tuple…
Q: Develop a JAVA program to computer the queries in X Y z format where you are given a list of size m.…
A: We have to write a Java program according to the given instructions. Algorithm: 1. Take input from…
Q: Develop a JAVA program to computer the queries in X Y z format where you are given a list of size m.…
A: In this question we have to write a Java program according to the given instructions. Algorithm:…
Q: a. Add the following operation to the class stackType : void reverseStack(stackType &otherStack);…
A: Objective: A function would be added to the stackType class to copy elements from an existing stack…
Q: Input1: A list containing 10 numbers Input2: A number,N Find a set of four numbers in the list…
A: Python is a high-level interpreted programming language, that's also used to build web browser…
Q: Write the program in Python Ms. Binny went to the automated Bins Supermarket where, on entering…
A: The python code of above scenario is attached below: Note: In Python indentation is important.…
Q: I got confused on how to write a code that acomplishes the task showed on the image attached (using…
A: Purpose: According to the given question, we need to develop a method that finds and returns the…
Q: Develop a JAVA program to computer the queries in X Y z format where you are given a list of size m.…
A: Required: We have to write a Java program according to the given instructions. Algorithm: 1. Take…
Q: Write a Python program that takes 7 inputs and appends them to a list (aGrades). Randomize the…
A: In the solution of problem, first we read grades and add into aGrades list using append() function.…
Q: Develop a JAVA program to computer the queries in X Y z format where you are given a list of size m.…
A: Code Flow: According to the given statement of the problem we need to upgrade the Java code to get…
Q: Presented with a list of X objects, Sebastian made a program in Python which does the following:…
A: If we notice cautiously the usefulness of both the techniques func1 and func2 are like turning the…
Q: . Random walkers. Write a program RandomWalkers.java that takes two integer command-line arguments r…
A: public class RandomWalk { public static void main(String[] args) { int n =…
Q: Write a program that reads a character, then reads in a list of words. The output of the program is…
A: c = input()words = input() list = words.split() for word in list: if c in word:…
Q: Implement in Java using ScheduledExecutorService the schedule(callable) method, that runs after a…
A: Given: Implement in Java using ScheduledExecutorService the schedule(callable) method, that runs…
Q: I need to write a java program to draw one of four recursively defined patterns.The patterns are in…
A: Below i have given code for the pattern:
Q: Scrabble is a word game in which words are constructed from letter tiles, each letter tile…
A: Program Approach: Create a dictionary to store letters with their values. Find each letter value of…
Q: Need help. Make a java program that creates squares at each corner recursively. Use the code…
A: import java.awt.Canvas; import java.awt.Graphics; import javax.swing.JFrame; The above packages…
Q: In Python Make a function that given an integer list of lists, returns a list of couples such as…
A: Step 1 : Start Step 2 : Define a function myFunction() to return a list of couple where the…
Q: Presented with a list of X objects, use a Single Linked List to make a program in Python which does…
A: I have created the entire program for you. I am attaching the python code below and the output as…
Q: Python's syntax is as follows: Print a list of all seats in a theater based on the parameters num…
A: Note: Please take care of indentation while writing the code.
Q: Develop a JAVA program to computer the queries in X Y z format where you are given a list of size m.…
A: We have to write a Java program according to the given instructions. Algorithm: 1. Take input from…
Q: Write a Python program that will ask a user for the weather and display what to do with it, refer to…
A: According to the asked question, the solution is given below with a proper explanation.
Q: Write a Python program that takes 7 inputs and appends them to a list (aGrades). Randomize the…
A: Note: The below python program takes "7" random scores and appends them to a list. Program: import…
Q: Based on assignment 1, write a Python code to create a list of sublists where each sublist contains…
A: Python Code: st=input("Enter characters: ")num=int(input("Enter number.: "))l=[]for i in st: for…
Q: Presented with a list of X objects, Mark made a program in Python which does the following: func_1 →…
A: def fun1(l): a=l[-1] for i in range(len(l)-1,0,-1): l[i]=l[i-1] l[1]=a; return…
Q: Write a Java program to implement the following: Ask the user to enter the names of 3 Books and…
A: syntax to create arraylist of size n ArrayList<String> book = new ArrayList<String>(n);…
Q: Sites like Zillow get input about house prices from a database and provide nice summaries for…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Read current_price,…
Q: only java program, a word search puzzle, where one is presented with a grid of letters and needs to…
A: Answer :-)
Q: In Java: Write a program that first gets a list of integers from input. The input begins with an…
A: Explanation: Read the number of integer in the list Loop to read all the integer values Read the…
Q: Write a python program that simulates the throwing of two dices for 200 times while using a list to…
A: EXPLANATION: - The random module is imported to generate random integers. The function…
Q: using Java, create a virtual shopping store. using the two txt files (items and sale), display a…
A: I have implemented the given requirements as per the instructions in Java. The code is as follows:…
Q: Write a Java program to do the following task :Create an integer array of size 15. Input the values…
A: Code:- import java.util.*;public class Main{ public static void main(String[] args) { Scanner sc…
Q: Write a java program that enables the user to enter a string and an index,then cuts the letter in…
A: Introduction: Write a java program that enables the user to enter a string and an index,then cuts…
Q: Write a program to build a calculator. Instead of a typical calculator which reads in-order…
A: Lets discuss the solution in the next steps
Q: Write a java program (One class with a main method) to do the following: 1. Prompt the user to enter…
A: Algorithm: 1.importing util package for scanner class 2.create object for scanner class to get…
Q: THIS IS MEANT TO BE IN JAVA Write a program that first gets a list of integers from input. The…
A: Given: Create a program that takes input and generates a list of integers. The first integer in the…
Q: Write a program that process 10 assessment marks of student. Input the marks and process the data to…
A: The program is written in C Language. Please find the program code and comments in step 2.
Q: Add a foreach loop at the end of the main method to print all the list elements side by side,…
A: List in Java provides the facility to maintain the ordered collection. It contains the index-based…
Q: =================================== Hint: The formula of distance = √((Δx)2+(Δy)2) As you are…
A: We need to create a list : points = [(1,7), (4,5), (-1,7), (-2,0), (1,1), (5,-1)] then iterate the…
Q: Write a Python program that takes a list as an input from the user.Then creates a new list excluding…
A: Let's see the code in the next steps
Q: Write a program using object oriented concepts to input a list of an array and then rearrange this…
A: Sample Response: //C++ program to arrange the odd at the beginning of array and even number at the…
Q: Write a python program to print the table of a number that is “1 greater” than the input number. For…
A: Define a function to find multiplication table. The function has parameter to print. Increment the…
Q: want my cashier system to automatically give the price after inputting the item name (not like what…
A: Task : Given the java code for the store management. The task is to use the concept of hashmap to…
- Designing an electronic voting machine is a challenging task. You are asked to implement a very simplified voting machine class with the following specification. A voting machine has a list of candidates and the following methods:
- a) addCandidate(String name) /* Add a candidate with the name to the list */
- b) castVote(String name) /* Cast a vote to the candidate with the name */
- c) printResults() /* Print out the number of votes each candidate has received. The order does not matter */
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images
- Write a program to build a calculator. Instead of a typical calculator which reads in-order expressions and evaluates them, build a calculator that takes in numbers and assigns the operations to yield the highest value expression. The current operations on the calculator only handle pairs of parentheses, and the operators for addition, subtraction, multiplication, and division. The calculator can rearrange the numbers if it helps find the optimal value. For example, the list:4.0 5.0 3.0 2.0 1.0using the calculator should find the optimal expression yielding the maximum value to be:4.0 * 5.0 * 3.0 * (2.0 + 1.0) = 180Input from the keyboard a list of up to 10 floating-point values from-100000.0to100000.0. Output to the screen a single floating-point value rounded to two decimal places representing the highest value expression that the calculator could create by inserting the symbols( ) + - * /into the given expression. Assume at least one number in the list and only the operators listed…Develop a simple program in Java to maintain a list of homework assignments. When an assignment is assigned, add it to the list, and when it is completed, remove it. You should keep track of the due date. Your program should 1. Add a new assignment. 2. Remove an assignment. 3. Provide a list of the assignments in the order they were assigned. 4. Find the assignment(s) with the earliest due date.Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain fewer than 20 words. Ex: If the input is: 5 hey hi Mark hi mark the output is: hey - 1 hi - 2 Mark - 1 hi - 2 mark - 1 Hint: Use two arrays, one array for the strings and one array for the frequencies import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner input = new Scanner(System.in); // Read the number of words int numWords = input.nextInt(); input.nextLine(); // Consume the newline character // Initialize arrays to store words and their frequencies String[] words = new String[numWords]; int[] frequencies = new int[numWords]; // Read and process the words for (int i = 0; i < numWords; i++) { String word = input.next(); boolean…
- A monochrome screen is stored as a single array of bytes, allowing eight consecutivepixels to be stored in one byte. The screen has width w, where w is divisible by 8 (that is, no byte willbe split across rows). The height of the screen, of course, can be derived from the length of the arrayand the width. Implement a function that draws a horizontal line from ( xl, y) to ( x2, y).The method signature should look something like:drawline(byte[] screen, int width, int xl, int x2, int y)Write a program in Python that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75.Write a C language program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. For coding simplicity, follow every output value by a space, including the last one. Such functionality is common on sites like Amazon, where a user can filter results.
- Write a java code program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Assume that the list will always contain less than 20 integers.Write a python program that will take a number a list of numbers(integer) as an input from the user and print whether the number is Awesome or not. Awesome number: a number where every digit is less than its immediate left digit is called an Awesome number. A single-digit number cannot be an awesome number(e.g. 5421 is an Awesome number.) ========================================================== **Sample Input1:**\ [976321, 321, 9763221, 9742, 876, 3211]\ **Sample Output1:**\ 976321 is an awesome number.\ 321 is an awesome number.\ 9763221 is a not-so-awesome number.\ 9742 is an awesome number.\ 876 is an awesome number.\ 3211 is a not-so-awesome number. ========================================================== **Sample Input2:**\ [97821, 97210, 979210]\ **Sample Output2:**\ 97821 is a not-so-awesome number.\ 97210 is an awesome number.\ 979210 is a not-so-awesome number. i wrote a code to check if the number is awesome or not. can you correct it and help me finish…Design and implement a simplified voting machine class with the following specification. Avoting machine has a list of candidates and the following methods:i) addCandidate(String name) /* Add a candidate with the name to the list */ii) castVote(String name) /* Cast a vote to the candidate with the name */iii) printResults() /* Print out the number of votes each candidate has received. Theorder does not matter */ Assume that only two attributes of a candidate, namely, the name and number of votes, are ofinterest here, and the size of the candidate list is unknown in advance.
- Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain fewer than 20 words. Ex: If the input is: 5 hey hi Mark hi mark the output is: hey - 1 hi - 2 Mark - 1 hi - 2 mark - 1 Hint: Use two arrays, one array for the strings and one array for the frequencies.Write a client program that loops around getting two fractions from the user,output their sum, and state whether or not they are equal. Keep looping until the first fraction entered is a zero fraction. import java.util.ArrayList;import java.util.Scanner; //Define the class Fractionclass Fraction{private int n, d;public Fraction(){//Initialize the valuesthis.n = this.d = 0;}public Fraction(int n, int d){//Initialize the variablesthis.n = n;this.d = d;}//Define the getter function getNum() that returns the numeratorpublic int getNum(){//Returns numeratorreturn n;}//Define the getter function getDen() that returns the denominatorpublic int getDen(){//Returns denominatorreturn d;}//Define the boolean function isZero() that returns 0 if numerator is 0 and denominator is not equals to zeropublic boolean isZero(){return(getNum() == 0 && getDen() != 0);}public boolean isequals(Object c){Fraction f = (Fraction) c;return(Integer.compare(n,f.n))==0 &&…Write a Java program to implement the following: Ask the user to enter the names of 3 Books and store them in an ArrayList called Book Remove the second book from the list Add the user to enter a new book name and store to be the first book of the list Ask the user to enter a book name, search for it in list, and print “exist” or “not exist” Print the book name at index 2 Print all list items using loop Print the size of the list