Problem Statement Write a C program that calculates your cur

Problem Statement: Write a C++ program that calculates your current grade in the class as well as predicts your grade depending on future grades. This assignment will contain functions for error checking, calculating the average, and prompting and getting input from the user. In this assignment, we are going to make a grade calculator!!! You will ask the user how many tests, assignments, labs, recitation quizzes, recitation critiques, recitation designs, and if there is a final for the class. Based on these numbers, you will prompt the user for the scores for each of the categories to calculate the average for a specific class. Scores/grades can be floating point numbers, and some categories have different point scales, not just out of 100. The scores for the labs are out of 10 pts (not 100!!!). The recitations grade is based on quizzes, design, and critiques, and each of these have different weights and point scales. For recitation score calculation, follow these rules:

The quizzes are out of different points for each quiz, 40% of recitation grade

The critiques are out of 20 pts, 20% of recitation grade

The designs are out of 10 pts, 40% of recitation grade Since we have categories, we need to know how much each category weighs in the percentage of the grade. For example, our class has the following percentages: labs – 10%, recitation – 20%, assignments – 30%, tests – 30%, final – 10%. If any category has a zero, then you will not prompt the user for weight or score!!!

The average will be calculated out of the total percentage of weights, not always 100%. This way you can get an accurate current grade in the class and use it as a predictor for a grade.

Example Run:

How many tests? 1

How many assignments? 2

How many labs? 4

How many recitation quizzes? 2

How many recitation critiques? 1

How many recitation designs? 1

Is there a final? 0

Weight for recitation quizzes? 40

Weight for recitation designs? 40

Weight for recitation critiques? 20

Recitation quiz 1 out of how many points? 5

Quiz 1 score: 5

Recitation quiz 2 out of how many points? 7

Quiz 2 score: 7

Recitation design score: 10

Recitation critique score: 20

Test 1 score: 100

Assignment 1 score: 100

Assignment 2 score: 100

Lab 1 score: 10

Lab 2 score: 10

Lab 3 score: 10

Lab 4 score: 10

Test weight: 30

Recitation weight: 20

Lab weight: 10

Assignment weight: 30

Your percentage in this class is: 100

For example, here are some functions you might want to have: start_calculator();

is_positive_int();

is_positive_float();

is_in_range();

calculate_average();

get_num_tests();

In addition, create any other functions you might need to properly modularize your code to 10 lines in each function.

Solution

#include <iostream>

#include <cstdio>

struct Student

{

void AssignEvals(char, FILE*);

public:

Student();

int Quiz;

int Assign;

int Labs;

int Tests;

void GetEvals(FILE*);

};

void Student::AssignEvals(char Letter, FILE* ReadFrom)

{

switch(Letter)

{

    case \'q\':

      fscanf(ReadFrom, \"%d\", &Quiz);

      break;

     

    case \'a\':

      fscanf(ReadFrom, \"%d\", &Assign);

      break;

     

    case \'l\':

      fscanf(ReadFrom, \"%d\", &Labs);

      break;

     

    case \'t\':

      fscanf(ReadFrom, \"%d\", &Tests);

      break;

     

    default:

      break;

}

}

Student::Student()

{

Quiz = Assign = Labs = Tests = 0;

}

void Student::GetEvals(FILE* ReadFrom)

{

char symbol;

do

{

    fscanf(ReadFrom, \"%c\", &symbol);

    symbol = tolower(symbol);//convert everything to lowercase

    AssignEvals(symbol, ReadFrom);

   

} while (symbol != \'f\' && !feof(ReadFrom));

}

int main(int argc, char *argv[])

{

if (argc < 2)

{

    std::cerr << \"Format for running program: \" << *argv << \" filename\ \";

    return 1;

}

FILE* readStream;

readStream = fopen(argv[1], \"r+\");

if (NULL == readStream)

{

    std::cerr << \"Corrupt file. Aborting\ \";

    return 1;   

}

else

{

    Student myStu;

   

    myStu.GetEvals(readStream);

   

    cout <<endl << myStu.Quiz << \" Quizzes, \" << myStu.Assign << \" Assignments, \"

    << myStu.Labs << \" Labs, \" << myStu.Tests << \" Tests\" << endl;

}

return 0;

}

Problem Statement: Write a C++ program that calculates your current grade in the class as well as predicts your grade depending on future grades. This assignmen
Problem Statement: Write a C++ program that calculates your current grade in the class as well as predicts your grade depending on future grades. This assignmen
Problem Statement: Write a C++ program that calculates your current grade in the class as well as predicts your grade depending on future grades. This assignmen
Problem Statement: Write a C++ program that calculates your current grade in the class as well as predicts your grade depending on future grades. This assignmen

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site