Question

In: Computer Science

Q1) Please create a C++ program that will ask the user for how many test scores...

Q1) Please create a C++ program that will ask the user for how many test scores will be entered. Setup a while loop with this loop iteration parameter. The data will include the student’s first name, Wayne State Access ID, midterm score and their favorite team (i.e. – Doug, hg1702, 92, Wolverines * - John, hv2201, 99, Warriors). Print out the completed test scores to a file (midTermScores.txt) . Adjust the output as follows: (15 points)
a. Scores with the highest grade should be listed first as in ascending order.
b. A letter grade should be in place of the numeric score using standard grading (a = 90 – 100, b=80-90, c=70-80, d=60-70, f=below 60)
c. The fields should be displayed with a total width of 15.
d. The fields should be printed with a header in the file explaining what each is:
i. First Name Access ID Test Score Favorite Team
ii. John hv2201 A Warriors
iii. Doug hg1702 A Wolverines



Q2) Please create a program that will ask a high school group that is made of 5 to 17 students to sell candies for a fund raiser. There are small boxes that sell for $7 and large ones that sell for $13. The cost for each box is $4 (small box) and $6 (large box). Please ask the instructor how many students ended up participating in the sales drive (must be between 5 and 17). The instructor must input each student’s First name that sold items and enter the number of each box sold each (small or large). Calculate the total profit for each student and at the end of the program, print how many students participated and the total boxes sold for each (small and large) and finally generate how much profit the group made. (15 points)

Solutions

Expert Solution

//Q1


#include<bits/stdc++.h>
using namespace std;
struct student
{
    string name;
    string ID;
    string grade;
    string team;
};
bool fn(struct student x,struct student y)
{
    return x.grade<=y.grade;
}
int main()
{
    int N,i;
  
    ofstream file;

    cout<<"Enter How many Test Score will be entered"<<endl;
    cin>>N;
  
    cout<<"enter ""Firt_NAME,Wayne State Access ID,midTermScores,Favorite_team"" for each student "<<endl;
  
    vector<struct student> v;
  
    while(N--)
    {
        int score;
        struct student s;
        cin>>s.name>>s.ID>>score>>s.team;
        if(score>=90&&score<=100)
        s.grade="A";
        if(score>=80&&score<90)
        s.grade="B";
        if(score>=70&&score<80)
        s.grade="C";
        if(score>=60&&score<70)
        s.grade="D";
        else if(score<60)
        s.grade="F";
        v.push_back(s);
    }
    sort(v.begin(),v.end(),fn);
  
    file.open ("midTermScores.txt");
    cout<<"First Name Access_ID Test_Score Favorite_Team";
  
    for(i=0;i<v.size();i++)
    {
        cout<<i+1<<" ";
        cout<<v[i].name<<v[i].ID<<v[i].grade<<v[i].team;
        cout<<endl;
    }
  
    file.close();
  
    return 0;
}


//Q2

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int N,x,y,T_sum,sum,i,a,b;
    string s;
    cout<<"please enter number of student participated in sales drive "<<endl;
    cin>>N;
    vector<pair<string,int>> v;
    cout<<"Enter students First name and number of each boxes sold each small and large"<<endl;
    T_sum=0;
    x=0;
    y=0;
    for(i=0;i<N;i++)
    {
        cin>>s>>a>>b;
        x+=a;
        y+=b;
        sum=(a*3)+(b*7);
        v.push_back(make_pair(s,sum));
        T_sum+=sum;
    }
  
    cout<<"Total number of student participated is"<<N<<endl;
    cout<<"Numebr of small boxes sold is "<<x<<" and Number of large boxes sold is "<<y<<endl;
    cout<<"total profit made by group is "<<T_sum<<endl;
  
    return 0;      
}


Related Solutions

Create a C++ program that will ask the user for how many test scores will be...
Create a C++ program that will ask the user for how many test scores will be entered. Setup a while loop with this loop iteration parameter. (no fstream) The data needs to include the student’s first name, student number test score the fields should be displayed with a total width of 15. The prompt should be printed with a header in the file explaining what each is: ex. First Name student number Test Score 1) mike 6456464   98 2) phill...
C++ program that will ask the user for how many test scores will be entered. Setup...
C++ program that will ask the user for how many test scores will be entered. Setup a while loop with this loop iteration parameter. The data will include the student’s first name and midterm score Print out the completed test scores to a file (midTermScores.txt) . Print out list of students names and grades in the print out, a letter grade should replace numeric score using standard grading (a = 90 – 100, b=80-90, c=70-80, d=60-70, f=below 60)
C LANGUAGE Ask user how many scores there are, then ask for each score. Then calculate...
C LANGUAGE Ask user how many scores there are, then ask for each score. Then calculate the average score and scores below 60. Then display the average score and number of scores below 60
Write a program in Java to: Ask the user how many scores they want to enter...
Write a program in Java to: Ask the user how many scores they want to enter (=> Create an array based the entered size) Ask the user to enter their scores in the quarter (Fill the array with the entered scores(assigned to elements)) ==>> Use a "for" loop Find the greatest score Calculate and show the average Show the final grade based on the average (For example A,B,C ... ) Print the scores (the elements of the array) => Use...
Write a program using C++ that ask the user for the flowing: How many shares to...
Write a program using C++ that ask the user for the flowing: How many shares to be bought: The price per share: Percent commission for the broker for each transaction: Average annual return as of percentage: The program should calculate and display the following: The amount paid for the stock alone (without the commission) The amount of the commissionThe total amount of paid (the payment for stock plus the commission) After TEN years, your shares will worth:
You have been asked to create a python program that will ask the user how many...
You have been asked to create a python program that will ask the user how many tickets the user would like to purchase for graduation. The user will then choose the number of tickets needed and the program will list the cost of the tickets, a service fee, tax, and the total of the purchase. Specifications: The program should only accept whole numbers when receiving input for the number of tickets needed. No calculations should be performed if input is...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will first enter a password, then enters the same password again; If the second input is the same as first one, the user successfully creates the password. Print “Well done.”; Otherwise, the user will be directed to repeat the whole process (go to step 1.)
write a program in c++ that asks the user to enter their 5 test scores and...
write a program in c++ that asks the user to enter their 5 test scores and calculates the most appropriate mean. Have the results print to a text file and expected results to print to screen.
Python Program Write a program that will ask a user on how many input colored balls...
Python Program Write a program that will ask a user on how many input colored balls of the following codes: R-red, B-blue, W-white, G-green and O-orange -will he or she would like to enter in the program and print the total number of Red balls were encountered. Assume an uppercase and lower case letter will be accepted.
Using (C programming language) Create a health monitoring program, that will ask user for their name,...
Using (C programming language) Create a health monitoring program, that will ask user for their name, age, gender, weight, height and other health related questions like blood pressure and etc. Based on the provided information, program will tell user BMI, blood pressure numbers if they fall in healthy range or not and etc. Suggestions can be made as what should be calorie intake per day and the amount of exercise based on user input data. User should be able to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT