Question



\Users\E0022485\source repos\Ch8_Ex6\Debug Ch8_ Processing Data KeTTFTFITTFTFTFFTTFTTF ABC54102 T FTFTFTTTFTTFTTF TE DEFS6278
C++ program to get this output

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

If you have any doubts, please give me comment...

#include <iostream>

#include <fstream>

#include <string>

#include <iomanip>

using namespace std;

char getGrade(double percent);

int main()

{

    ifstream inFile;

    string data;

    char space;

    char *answers = new char[21];

    unsigned int i;

    inFile.open("Ch8_Ex6Data.txt");

    inFile >> answers;

    cout<<"Processing Data"<<endl;

    cout<<"Key:  "<<answers<<endl;

    while (!inFile.eof())

    {

        i = 0;

        int total_marks = 0;

        char grade;

        string studentID;

        inFile >> studentID;

        inFile.get(space);

        getline(inFile, data);

        // cout<<endl<<endl;

        while (i < data.length())

        {

            //cout<<data[i+1]<<" "<<answers[i]<<endl;

            if (data[i] == answers[i])

            {

                total_marks += 2;

            }

            else if (data[i] != ' ')

            {

                total_marks -= 1;

            }

            i++;

        }

        cout << studentID << " " << setw(20)<<left<<data << " " << total_marks;

        double dpercent = (double)((total_marks * 100) / 40);

        grade = getGrade(dpercent);

        cout << " " << grade << endl;

    }

    return 0;

}

char getGrade(double percent)

{

    char grade;

    if (percent > 90)

        grade = 'A';

    else if (percent > 80)

        grade = 'B';

    else if (percent > 70)

        grade = 'C';

    else if (percent > 60)

        grade = 'D';

    else

        grade = 'F';

    return grade;

}

nagarajuanagaraju-Vostro-3550:09122019$ g++ tf_grades.cpp nagarajuanagaraju-Vostro-3550:09122019$ a.out Processing Data Key:

Add a comment
Know the answer?
Add Answer to:
C++ program to get this output \Users\E0022485\source repos\Ch8_Ex6\Debug Ch8_ Processing Data KeTTFTFITTFTFTFFTTFTTF ABC54102 T FTFTFTTTFTTFTTF TE...
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
  • Use C++ For this week’s lab you will write a program to read a data file...

    Use C++ For this week’s lab you will write a program to read a data file containing numerical values, one per line. The program should compute average of the numbers and also find the smallest and the largest value in the file. You may assume that the data file will have EXACTLY 100 integer values in it. Process all the values out of the data file. Show the average, smallest, largest, and the name of the data file in the...

  • C++ Exercise#1: Reverse list Write a program that prompts the user to enter a list of...

    C++ Exercise#1: Reverse list Write a program that prompts the user to enter a list of 10 integer numbers, list. Your program should replace each multiples of 4 number with 0 in list. Produces the output as in the sample input/output below Sample input/output C:AUsers 10064 Documents My Courses 14111161Spring 20151Lab.. ease enter ist ers: 1 he input list after processing: 0 34 45 65 0 99 85 10 30 rocess returned 0 (0x0) execution time: 34.398 s ress key...

  • PLEASE HELP ME WITH THIS TASK 3.1 (FLOWCHART) AND TASK 3.2 (SOURCE PROGRAM). THANK YOU! Hint:...

    PLEASE HELP ME WITH THIS TASK 3.1 (FLOWCHART) AND TASK 3.2 (SOURCE PROGRAM). THANK YOU! Hint: the number array in task 2 is work for task 3 in figure 1.   Given below is a partially completed C program, which you will use as a start to complete the given tasks. #define SIZE 9 #include <stdio.h> int compareAndCount (int[], int[]); double averageDifference (int[], int[]); void main() { } int compareAndCount(int arr1[SIZE], int arr2[SIZE]) { int count = 0; for (int i...

  • In c++ Write a program that asks users to input the amount of money (in cents)...

    In c++ Write a program that asks users to input the amount of money (in cents) that will be exchanged to the least number of coins of the same value, output the results. Assume there are quarters (25c), dimes (10c), nickels(5c) and pennies(1c) available. ■CA 32 cmd.e eas input the anount of money (in cents) you want to exchange 39 39 can be exchanged to uarter: 25 me: 1 kel: e enny: 4 ress any key to continue-.

  • PLEASE HELP ME WITH THIS TASK 3.1 (FLOWCHART) AND TASK 3.2 (SOURCE PROGRAM). THANK YOU! Given...

    PLEASE HELP ME WITH THIS TASK 3.1 (FLOWCHART) AND TASK 3.2 (SOURCE PROGRAM). THANK YOU! Given below is a partially completed C program, which you will use as a start to complete the given tasks. #define SIZE 9 #include <stdio.h> int compareAndCount (int[], int[]); double averageDifference (int[], int[]); void main() { } int compareAndCount(int arr1[SIZE], int arr2[SIZE]) { int count = 0; for (int i = 0; i < SIZE; i++) { if (arri[i] > arr2[i]) count++; } return count;...

  • Given below is a partially completed C program, which you will use as a start to...

    Given below is a partially completed C program, which you will use as a start to complete the given tasks. #define SIZE 9 #include <stdio.h> int compareAndCount (int[], int[]); double averageDifference (int[], int[]); void main() { } int compareAndCount(int arr1[SIZE], int arr2[SIZE]) { int count - @; for (int i = 0; i < SIZE; i++) { if (arri[i] > arr2[i]) count++; return count; Task 1: (10 pts) Show the design of the function compareAndCount() by writing a pseudocode. To...

  • Using c++ , screenshot of display output as well. Preferably using visual studio. The output is...

    Using c++ , screenshot of display output as well. Preferably using visual studio. The output is Random I believe doesn’t have to be the same, Attached is the input a & b txt file as well. Question -1: input_a.txt is provided on Blackboard to populate the linked list. Write a function in C++ program that will take the head of the linked list and remove the duplicate values from the list. Perform operations on a singly linked list. CAWINDOWSlsystem321cmd.exe Linked...

  • The answer need to write in C programming. QUESTION 2 Write a program using array to...

    The answer need to write in C programming. QUESTION 2 Write a program using array to generate a multiplication table based on the user's input. For example if user enter 5 as input then a multiply table for 1 to 5 is printed as output as shown in Figure Q2. There are three main steps in this program which are: Print rows (a) (b) Print columns Print multiplication of data inside table (c) Select C:\example1 \bin\Debuglexample 1.exe enter the value...

  • Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write...

    Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write a program to ask the user for a number that includes a decimal point. Then display the integer part of the number (the part of the number to the left of the decimal point) and the decimal part of the number (the part of the number to the right of the decimal point, including the decimal point Follow the 3 steps in the Information...

  • 1. Write a C++ program that reads sides of a triangle a, b and c from a file and computes the are...

    1. Write a C++ program that reads sides of a triangle a, b and c from a file and computes the area of a triangle and counts total number of areas program has computed Program should have two functions sfun(): sfun receives the values of a, b and c then computes and returns the value ofs as areafun 0: areafun receives the value of s and computes and return the area of a triangle to main program using below formulae...

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