Question

I was looking for help with a computer science c programming class. not c++ This program...

I was looking for help with a computer science c programming class. not c++

This program will have menu system. The menu will at least have the following options:

                        ***********************************************************

                        **                   MAIN MENU **

                        ***********************************************************

  1. Enter Votes from a state for Donald Trump
    • Choose State
    • Enter Number of Votes
  2. Enter Votes from a state for Joe Biden
    • Choose State
    • Enter Number of Votes
  3. Display total votes for each candidate
  4. List the state name(s) where candidate tied
  5. For each candidate display the highest and lowest votes
  6. Election is over, Exit Program

could someone please point me in the right direction

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

//structure for election info
struct Election
{
//stateNum will store the number of a state
//use an array for multi state election
int stateNum;
  
//use an array for multi state election
//each element will store the votes for a single state
int votes;
};

//funciton to display the state list
void stateList()
{
printf("\nPress 1: For California");
printf("\nPress 2: For Florida");
printf("\nPress 3: For Hawali");
}

int main()
{
struct Election candidate[2];
  
char stateStr[3][20] = {"California", "Florida", "Hawali"};
printf("Enter votes from a state for Donald Trump");
stateList();
printf("\n\nChoose State: ");
  
scanf("%d", &candidate[0].stateNum);
printf("\nEnter the number of votes: ");
scanf("%d", &candidate[0].votes);
  
printf("\nEnter votes from a state for Joe Biden");
stateList();
printf("\n\nChoose State: ");
  
scanf("%d", &candidate[1].stateNum);
printf("\nEnter the number of votes: ");
scanf("%d", &candidate[1].votes);
  
//display total votes
printf("\nTotal votes for Donald Trump: %d", candidate[0].votes);
printf("\nTotal votes for Joe Biden: %d", candidate[1].votes);
  
//display highest and lowest score
printf("\n\nThe lowest score for Donald Trump: %d", candidate[0].votes);
printf("\nThe highest score for Donald Trump: %d", candidate[0].votes);
printf("\n\nThe lowest score for Joe Biden: %d", candidate[1].votes);
printf("\nThe highest score for Joe Biden: %d", candidate[1].votes);
  
//check if candidate tie
if((candidate[0].votes == candidate[1].votes) && (candidate[0].stateNum == candidate[1].stateNum))
{
printf("\n\nCandidate tie in %s", stateStr[candidate[0].stateNum]);
}
  
return 0;
}

OUTPUT:

Enter votes from a state for Donald Trump
Press 1: For California
Press 2: For Florida
Press 3: For Hawali

Choose State: 2

Enter the number of votes: 20000

Enter votes from a state for Joe Biden
Press 1: For California
Press 2: For Florida
Press 3: For Hawali

Choose State: 2

Enter the number of votes: 20000

Total votes for Donald Trump: 20000
Total votes for Joe Biden: 20000

The lowest score for Donald Trump: 20000
The highest score for Donald Trump: 20000

The lowest score for Joe Biden: 20000
The highest score for Joe Biden: 20000

Candidate tie in Hawali

Add a comment
Know the answer?
Add Answer to:
I was looking for help with a computer science c programming class. not c++ This program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please post following code with criteria below... please leave as many comments as possible Exam Four:...

    Please post following code with criteria below... please leave as many comments as possible Exam Four: the election Outcome: Student will demonstrate all core competencies from this class: Program Design (design tools) Variables Decision Error Checking Looping Functions Arrays Program Specifications: Let’s pretend that we are tracking votes for the next presidential election. There will be two candidates: Ivanka Trump and Michele Obama. You can assume that there are fifty states casting votes. You will do not need to deal...

  • I was looking for help in my computer programming class. The program I need to create...

    I was looking for help in my computer programming class. The program I need to create is this. Program Specifications: Write a C program what will read in one word. Store this word in an array. Hint: char myWord[SIZE] = ‘ ‘; Once you store the word, you are to do the following four things: Display: The word is: abcdefg Display: The word backwards is: gfedcba Display: The word vertical is: A B C D E F G Display: The...

  • (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates...

    (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates for an upcoming election. This program needs to allow the user to enter candidates and then record votes as they come in and then calculate results and determine the winner. This program will have three classes: Candidate, Results and ElectionApp Candidate Class: This class records the information for each candidate that is running for office. Instance variables: first name last name office they are...

  • THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #inclu...

    THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #include "pch.h" #include #include using namespace std; // Function prototype void displayMessage(void); void totalFees(void); double calculateFees(int); double calculateFees(int bags) {    return bags * 30.0; } void displayMessage(void) {    cout << "This program calculates the total amount of checked bag fees." << endl; } void totalFees() {    double bags = 0;    cout << "Enter the amount of checked bags you have." << endl;    cout <<...

  • Your job is to write a program that will help us keep track of the donations to these candidates....

    Help with C++ Code (using visual studio) preferred Typed Result: Your job is to write a program that will help us keep track of the donations to these candidates. You will assume that the program is written for this election where Anders and Valerie are running. It is OK to hard code these into your program. Don't worry about case sensitivity of names Here are the features of the program Feature #1: Contribute to a Campaign [60 points] When someone...

  • I am struggling with a program in C++. it involves using a struct and a class...

    I am struggling with a program in C++. it involves using a struct and a class to create meal arrays from a user. I've written my main okay. but the functions in the class are giving me issues with constructors deconstructors. Instructions A restaurant in the Milky way galaxy called “Green Alien” has several meals available on their electronic menu. For each food item in each meal, the menu lists the calories per gram and the number of grams per...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================")...

    Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================") print(" Baseball Team Manager") print("MENU OPTIONS") print("1 - Calculate batting average") print("2 - Exit program") print("=====================================================================")    def convert_bat(): option = int(input("Menu option: ")) while option!=2: if option ==1: print("Calculate batting average...") num_at_bats = int(input("Enter official number of at bats: ")) num_hits = int(input("Enter number of hits: ")) average = num_hits/num_at_bats print("batting average: ", average) elif option !=1 and option !=2: print("Not a valid...

  • use C++ programming language and follow the instruction carefully. thanks! Inputs: . [integer] values (10 times)...

    use C++ programming language and follow the instruction carefully. thanks! Inputs: . [integer] values (10 times) Outputs: • [integer) highest value . [integer] lowest value Description: Write a program that lets the user enter 10 values. These values should be stored in an array. Your program will then find the highest and lowest values in the array. Your program will display the list of number as a comma separated list, and print which values is the highest and lowest Do...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT