Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please and Thank You Hi I’m having trouble building the code for this assignment

ID: 3828568 • Letter: P

Question

Please and Thank You

Hi I’m having trouble building the code for this assignment. need help

C++ visual studio

THE CODE NEEDS TO BE EXTREMELY SIMPLE.

THE CODE NEEDS TO BE EXTREMELY SIMPLE.

THE CODE NEEDS TO BE EXTREMELY SIMPLE.

THE CODE NEEDS TO BE EXTREMELY SIMPLE.

Simple things like

Classes

Objects

Arrays

Varabiles / properties / fields / methods of a class

Iostream

String

Frstream

Not much of anything more

Here is the assignment --- the picture of how it turns out is attached.

The election season is upon us. The amount of money a candidate raises against his/her opponent greatly affects the outcome of the election. Anders and Valerie (completely fictional characters) are two fierce opponents fighting for the democratic party nomination.

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 wants to make a contribution we use this feature to enter the contribution information to the system. Program asks for which candidate the contribution is, and the amount of the contribution, along with the name of the person making the contribution.

To make things easier for you -- You may assume that the name of the donor is just the last name. No spaces allowed in the last name and assume that no two donors will ever have the same last name. :-)

According to US laws, no individual is allowed to make political contributions exceeding $2700 per election. The program should not accept the contribution if the total amount of contribution of that individual (go by last name) exceeds $2700 [50 points].

The candidate that will be entered by the user will always be either Anders

or Valerie -- you do not need to error check for this.

The program supports up to 1000 donations.

Feature #2: Report per Candidate

a) Displays how many contributions are in the system for each candidate. [30 points]

b) The total amount contributed for each candidate. [30 points]

c) The average contribution amount for each candidate. This is basically the number you found for a) divided by the number you reported for b) for each candidate. [30 points]

File I/O [60 points]: Make sure that you have file I/O in place so we do not loose information when we close the program.

Classes [40 points]: Make sure that you are using a class representing a donation..

Avoid Penalties:

- Each feature must be in a separate function (-60). You must use arrays to hold the data (-60)

- Your program does not compile and/or crashes while running (-60).

- Your program is not properly indented and/or commented (-60).

- Global variables are not allowed (-60).

Assume that I will deduct the maximum amount if you hit these penalties. I will also deduct the maximum amount if any of the features of the program is not functioning properly

---------------------------------------

here is some of it but it is missing FILE I/O and Classes

-----------------------------------------------------------------------------------------

File I/O: Ability to read data from file and ability to write data to a file.

Step 1: include fstream library

Step 2: make sure the file is located inside the same folder as the project file of the program. Once compiled, the file should be in the same folder as the executable file (*.exe).

Step 3: make sure extensions are not hidden!.

- On your computer, open up My computer,

- hit Alt button to make the menu visible

- on the menu, Tools > Folder Options,

- go to View tab

- make sure "Hide extensions for known file types" is UNCHECKED.

- Hit OK to close.

Step 4: open up the file for reading or writing. ifstream to open for reading. ofstream to open for writing.

Step 5: keep reading the file like reading from keyboard.

file.eof() gets you if you are at the end of the file.

Step 6: file.close(); to close the file when we are done.

---------------------------------------------------------

Example of class - not for this, this is a sample for loans, not contributions

class Loan
{
public:
   int Age;
   int Score;
   int Amount;

   double GetRiskFactor()
   {
       double ageFactor = 1;

       if (Age < 30)
       {
           ageFactor = 1.4;
       }
       else if (Age < 50)
       {
           ageFactor = 1.2;
       }

       int riskFactor = (Amount / Score) * ageFactor;
       return riskFactor;
   }
};

--------------------------------------------

here is the code but as i said it is

im trying to put in file I/o and classes please help!

#include <iostream>
#include <string>

using namespace std;

int main()
{
int option; // user's entered option will be saved in this variable
int amt=0, amt1=0, tot=0, tot1=0, i=0, j=0, g=0, h=0;
string name, name1;

do //do-while loop starts here.that display menu again and again until user select to exit program
{
//Displaying Options for the menu
cout << " ============================";
cout << " Election Contributors v1.0 Anders vs Valerie" << endl;
cout << " ============================";
cout << " 1 - Contribute to a campaign " << endl;
cout << "2 - Report per Candidate" << endl;
cout << "0 - Exit " << endl;
//Prompting user to enter an option according to menu
cout << "Make a choice(0-1) : ";
cin >> option; // taking option value as input and saving in variable "option"

if(option == 1) // Checking if user selected option 1
{
cout<<" Candidate (Anders or Valerie) : ";
cin>>name;

if(name=="Anders"){
   
    cout<<" Donation amount : ";
    cin>>amt;
   
    cout<<" Your Name : ";
    cin>>name1;
   
    tot = tot+amt;
    i++;
   
    if(tot>2700){
       
        tot = tot-amt;
        cout<<" You cannot exceed $2700 per election ";
        i--;
       }
    }
   else if(name=="Valerie"){
     
    cout<<" Donation amount : ";
    cin>>amt1;
   
    cout<<" Your Name : ";
    cin>>name1;
          
    tot1 = tot1+amt1;
    j++;
    if(tot1>2700){
       
        tot1 = tot1-amt1;
        cout<<" You cannot exceed $2700 per election ";
        j--;
       }  
          
   }
   else cout<<" Invalid name";
}
else if(option == 2) // Checking if user selected option 2
{
if(i>0)
       g = tot/i;
      
cout<<" Anders:";
cout<<" Total: $"<<tot;
cout<<" # of Donations: "<<i;
cout<<" Avg Amount: $"<<g;
     
   if(j>0)
      h = tot1/j;
   cout<<" Valerie:";
cout<<" Total: $"<<tot1;
cout<<" # of Donations: "<<j;
cout<<" Avg Amount: $"<<h<<" ";
}
else if(option == 0) // Checking if user selected option 4
{
cout << "Terminating Program" << endl;
}
else //if user has entered invalid choice (other than 1,2,3 or 4)
{
//Displaying error message
cout << "Invalid Option entered" << endl;
}
}
while(option != 0); //condition of do-while loop

return 0;
}

-----------------------------------------------------

Election Contributions v1.0 Anders vs. Valerie 1- Contribute to a Campaign 2- Report per Candidate 0- Exit Make a choice (1-3): 1 Candidate (Anders or Valerie): Anders Donation Amount: 1300 Your Name: Jackson Election Contributions v1.0 Anders vs. Valerie 1- Contribute to a Campaign 2- Report per Candidate 0- Exit Make a choice (1-3): 1 Candidate (Anders or Valerie Anders Donation Amount 1500 Your Name: Jackson You cannot exceed $2700 per election Election Contributions v1.0 Anders vs. Valerie 1- Contribute to a Campaign 2- Report per Candidate 0- Exit Make a choice (1-3): 2 Anders: Total: $1300 of Donations: 1 Aug. Amount: $1300 Valerie: Total $0 H of Donations: 0 Aug. Amount $0 Election Contributions v1.0 Anders vs. Valerie 1- Contribute to a Campaign 2- Report per Candidate 0- Exit Make a choice (1-3): 1 Candidate (Anders or Valerie Valerie Donation Amount 500 Your Name: Brown Election Contributions v1.0 Anders vs. Valerie 1- Contribute to a Campaign 2- Report per Candidate 0- Exit Make a choice (1-3): 2 Anders: Total: $1300 of Donations: 1 Avg Amount: $1300 Valerie: Total $1500 H of Donations: 1

Explanation / Answer

#include <iostream>
#include <string>

using namespace std;

int main()
{
int option; // user's entered option will be saved in this variable
int amt=0, amt1=0, tot=0, tot1=0, i=0, j=0, g=0, h=0;
string name, name1;

do //do-while loop starts here.that display menu again and again until user select to exit program
{
//Displaying Options for the menu
cout << " ============================";
cout << " Election Contributors v1.0 Anders vs Valerie" << endl;
cout << " ============================";
cout << " 1 - Contribute to a campaign " << endl;
cout << "2 - Report per Candidate" << endl;
cout << "0 - Exit " << endl;
//Prompting user to enter an option according to menu
cout << "Make a choice(0-1) : ";
cin >> option; // taking option value as input and saving in variable "option"

if(option == 1) // Checking if user selected option 1
{
cout<<" Candidate (Anders or Valerie) : ";
cin>>name;

if(name=="Anders"){
   
    cout<<" Donation amount : ";
    cin>>amt;
   
    cout<<" Your Name : ";
    cin>>name1;
   
    tot = tot+amt;
    i++;
   
    if(tot>2700){
       
        tot = tot-amt;
        cout<<" You cannot exceed $2700 per election ";
        i--;
       }
    }
   else if(name=="Valerie"){
     
    cout<<" Donation amount : ";
    cin>>amt1;
   
    cout<<" Your Name : ";
    cin>>name1;
          
    tot1 = tot1+amt1;
    j++;
    if(tot1>2700){
       
        tot1 = tot1-amt1;
        cout<<" You cannot exceed $2700 per election ";
        j--;
       }  
          
   }
   else cout<<" Invalid name";
}
else if(option == 2) // Checking if user selected option 2
{
if(i>0)
       g = tot/i;
      
cout<<" Anders:";
cout<<" Total: $"<<tot;
cout<<" # of Donations: "<<i;
cout<<" Avg Amount: $"<<g;
     
   if(j>0)
      h = tot1/j;
   cout<<" Valerie:";
cout<<" Total: $"<<tot1;
cout<<" # of Donations: "<<j;
cout<<" Avg Amount: $"<<h<<" ";
}
else if(option == 0) // Checking if user selected option 4
{
cout << "Terminating Program" << endl;
}
else //if user has entered invalid choice (other than 1,2,3 or 4)
{
//Displaying error message
cout << "Invalid Option entered" << endl;
}
}
while(option != 0); //condition of do-while loop

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote