Question

our program using the following data Mary Smith Green walley Thul Bool Gauteng ) Please key is the n ot your Ter in your mark

QUESTION 2: (40) Suppose we want to compile a student academic report for a high school learner in grade 12 (matric). A matri

our program using the following data Mary Smith Green walley Thul Bool Gauteng ) Please key is the n ot your Ter in your mark

C++

QUESTION 2: (40) Suppose we want to compile a student academic report for a high school learner in grade 12 (matric). A matri

COS1511/102/1/2020 Sample run: Please key in your name: John Africa Please key in the name of your school: Kings College Key

e. A function passor Fail, to determine whether the student has passed or failed grade 12. (9) f. A function awardDistinction

The programming language is c++

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

#CODE

#include <iostream> #include <algorithm> #include <iomanip> using namespace std; string subjects[6] = {"English","Mathematics","Life Orientation","History","Computer literacy","Art"}; int code[7] = {7,6,5,4,3,2,1}; string symbol[7] = {"A","B","C","D","E","F","FF"}; void studentDetails(){ string name,school_name; cout << "Please key in your name: "; getline(cin,name); cout << "Please key in the name of your school: "; getline(cin,school_name); cout << "Name: " << name << "\t" << "School: " << school_name << endl << endl; } void getMarks(int marks[6]){ for(int i=0;i<6;i++){ int mark; cout << "Key in your mark for " << subjects[i] << ": "; cin >> mark; if(mark>=0 && mark<=100) marks[i] = mark; else{ i--; cout << "Enter marks >=0 and <=100" << endl; continue; } } } float calcAverageYearMark(int marks[6]){ float avg = 0; for(int i=0;i<6;i++){ avg = avg + marks[i]; } avg = avg/(float)6; return avg; } void MinMax(int marks[]){ int n = 6; int min = *min_element(marks,marks+6); int max = *max_element(marks,marks+6); cout << "The Highest mark was " << max << "%" << endl; cout << "The Lowest mark was " << min << "%" <<endl; } void passOrfail(int marks[]) { int ct = 0; for(int i=0;i<6;i++){ if(marks[i]>29 && marks[i]<=100){ ct++; } } if(ct == 6){ cout << "Passed" << endl; } else cout << "Failed" << endl; } int codeSymbol(int marks[],int c[],string s[],float avg){ int k; for(int i=0;i<6;i++){ if(marks[i]>=80 && marks[i]<=100){ s[i] = symbol[0]; c[i] = code[0]; k = 0; } else if(marks[i]>=70 && marks[i]<=79){ s[i] = symbol[1]; c[i] = code[1]; k =1; } else if(marks[i]>=60 && marks[i]<=69){ s[i] = symbol[2]; c[i] = code[2]; k = 2; } else if(marks[i]>=50 && marks[i]<=59){ s[i] = symbol[3]; c[i] = code[3]; k =3; } else if(marks[i]>=40 && marks[i]<=49){ s[i] = symbol[4]; c[i] = code[4]; k =4; } else if(marks[i]>=30 && marks[i]<=39){ s[i] = symbol[5]; c[i] = code[5]; k = 5; } else if(marks[i]>=0 && marks[i]<=29){ s[i] = symbol[6]; c[i] = code[6]; k = 6; } } for(int i=0;i<6;i++){ if(avg>=80 && avg<=100){ k = 0; } else if(avg>=70 && avg<=79){ k =1; } else if(avg>=60 && avg<=69){ k = 2; } else if(avg>=50 && avg<=59){ k =3; } else if(avg>=40 && avg<=49){ k =4; } else if(avg>=30 && avg<=39){ k = 5; } else if(avg>=0 && avg<=29){ k = 6; } } return k; } void awardDistinction(int marks[],float avg){ string lev[6]; if(avg>=75 && avg<=100){ cout << "Distinction" ; } for(int i=0;i<6;i++){ if(marks[i]>=75 && marks[i]<=100){ lev[i] = "Distinction"; } else lev[i] = "No Distinction"; } } void studentReport(){ cout << string(30,'*') <<endl; cout << setw(5) << "STUDENT ACADEMIC RECORD" << endl; cout << "This program inputs the learner marks of matric\n"; cout << "level subjects and prints the student final report.\n"; cout << string(30,'*') <<endl; studentDetails(); int marks[6]; getMarks(marks); int cd[6],k; string symb[6]; float avg = calcAverageYearMark(marks); k = codeSymbol(marks,cd,symb,avg); cout << setw(20) << "Subject" << setw(10) << "Mark" << setw(10) << "Symbol" << setw(10) <<"Code" << endl; for(int i=0;i<6;i++){ cout << setw(20) << subjects[i] << setw(10)<< marks[i] << "%" << setw(10) << symb[i] << setw(10) << cd[i] << endl; } cout << "Average Year Mark: " << avg << " with Symbol " << symbol[k] << " and Code " << code[k] << endl; cout << "Outcome: ";passOrfail(marks); MinMax(marks); } int main() { studentReport(); return 0; }

#OUTPUT

Run: learning_cpp X C:\Users\SS\CLion Projects learning_cpp cmake-build-debug learning_cpp.exe 来来来来来来来来来来来来来来来来来来来来来来来来来来来来来来

For any queries regarding this please comment.

Thank You.

Add a comment
Know the answer?
Add Answer to:
C++ The programming language is c++ our program using the following data Mary Smith Green walley...
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
  • using C language Programming Question 1 Write a C program that takes students marks from a...

    using C language Programming Question 1 Write a C program that takes students marks from a user, one by one until -1" is entered, which would indicate that no other marks are available, and the program terminates. For each mark the program will decide the student grade as: Fail, if mark < 60 • D. if 60<= mark <=70 • C. if 70<=mark <=80 • B. if 80c= mark <=90 • A. if 90cmark <=100 -T -- E - 15203...

  • C++ Question Write a program that will calculate a student's year marks for all his subjects.

    Write a program that will calculate a student's year marks for all his subjects. The program must read the subject code, the assignment marks for two assignments and the percentage that each assignment contributes towards the year mark, for each subject that the student is registered for.Create an input file called assignments.dat that contains the following information for a specific student:The first field in each line represents the subject code, followed by the percentage that assignment 1 contributes towards the...

  • Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a...

    Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a main function and three other functions called. readmarks , changemarks (, and writemarks() The program begins by calling the function readmarks () to read the input file marksin. txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float). Once the ID numbers and marks have been read into arrays (by readmarks () the...

  • For each problem, you must: Write a Python program Test, debug, and execute the Python program...

    For each problem, you must: Write a Python program Test, debug, and execute the Python program Save your program in a .py file and submit your commented code to your Student Page. Note regarding comments: For every class, method or function you create, you must provide a brief description of the what the code does as well as the specific details of the interface (input and output) of the function or method. (25 pts.) Write a program that reads in...

  • C programming. 1.Create a program that does the following - Creates three pointers, a character pointer...

    C programming. 1.Create a program that does the following - Creates three pointers, a character pointer professor, and two integer pointers student_ids, grades - Using dynamic memory, use calloc to allocate 256 characters for the professor pointer - Prompts the professor for their name, and the number of students to mark. - Stores the professor’s name using the professor pointer and in an integer the number of students to mark. - Using dynamic memory, use malloc to allocate memory for...

  • In the language c using the isspace() function: Write a program to count the number of...

    In the language c using the isspace() function: Write a program to count the number of words, lines, and characters in its input. A word is any sequence of non-white-space characters. Have your program continue until end-of-file. Make sure that your program works for the case of several white space characters in a row. The character count should also include white space characters. Run your program using the following three sets of input:             1. You're traveling through ​               another...

  • C - language please 1. Create a program that does the following, make sure you can...

    C - language please 1. Create a program that does the following, make sure you can complete this before moving to further questions, when compiling add the -Ipthread argument, if you are using gcc use the -pthread argument. Creates two threads, the first uses a function hello world() which prints hello world, the second uses a function goodbye() which prints goodbye. • Each function has a random sleep duration before printing the output - After running your program a few...

  • In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, t...

    In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...

  • Using C programming language Question 1 a) through m) Exercise #1: Write a C program that...

    Using C programming language Question 1 a) through m) Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. a. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. b....

  • ONLY REQUIRE C Problem statement: You are to write a program that manages student marks for...

    ONLY REQUIRE C Problem statement: You are to write a program that manages student marks for a class. Student marks are stored as a 2D array. Each row represents the marks of one student. Each column represents one assessment. For example, if we have two students and 3 assessment items with the marks for student1 being (67.6,88.5, 75.4} and student2 being (77.5, 76.2,78.3} our 2D array would look like: 67.6, 38.5,75.4 77.5, 76.2,78.3 You are to write a script/main function...

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