Modify Assignment #18 so it drops each student’s lowest score when determining the students’ test score average and Letter grade. No scores less than 0 or greater than 100 should be accepted
#include<iostream>
#include<string>
using namespace std;
int main()
{
double average[5];
string name[5];
char grade[5];
for(int i=0; i<=5; i++)
{
cout<<"Enter student name: ";
cin.ignore();
getline(cin,name[i]);
int sum=0;
for(int j=0; j<5; j++)
{
int grades;
cout<<"Enter Grades:"<<j+1<<" : ";
cin>>grades;
sum+=grades;
}
average[i]=(float)sum/5;
if(average[i]>=90 && average[i]<=100)
grade[i]='A';
else if(average[i]>=80 && average[i]<=89)
grade[i]='B';
else if(average[i]>=70 && average[i]<=79)
grade[i]='C';
else if(average[i]>=60 && average[i]<=69)
grade[i]='D';
else if(average[i]>=0 && average[i]<=59)
grade[i]='F';
}
cout<<"Name\tAverage\tMarks"<<endl;
for(int i=0; i<5; i++)
{
cout<<name[i]<<"\t"<<average[i]<<"\t"<<grade[i]<<endl;
}
}
#include<iostream>
#include<string>
using namespace std;
int main()
{
double average[5];
string name[5];
char grade[5];
for(int i=0; i<5; i++)
{
cout<<"Enter student name: ";
cin.ignore();
getline(cin,name[i]);
int sum=0;
int min=100;
for(int j=0; j<5; j++)
{
int grades;
cout<<"Enter Grades:"<<j+1<<" : ";
cin>>grades;
//checking whether grade is less than 0 or greater than 100
if(grades<0 || grades>100){//if condition
satisfies re-entering the value
cout<<"Invalid grades!!! Please re-enter\n";
j--;
}
else{
sum+=grades;
if(min > grades){//storing minimum grade in min
variable
min = grades;
}
}
}
sum = sum - min;//dropping minimum grade
average[i]=(float)sum/4;//now average is taken
from 4 grades
if(average[i]>=90 &&
average[i]<=100)
grade[i]='A';
else if(average[i]>=80 &&
average[i]<=89)
grade[i]='B';
else if(average[i]>=70 &&
average[i]<=79)
grade[i]='C';
else if(average[i]>=60 &&
average[i]<=69)
grade[i]='D';
else if(average[i]>=0 &&
average[i]<=59)
grade[i]='F';
}
cout<<"Name\tAverage\tMarks"<<endl;
for(int i=0; i<5; i++)
{
cout<<name[i]<<"\t"<<average[i]<<"\t"<<grade[i]<<endl;
}
}
OUTPUT :
Hope this helps you!!!
Modify Assignment #18 so it drops each student’s lowest score when determining the students’ test score...
This is what I have as of right now. I am lost on what to do next#include <stdio.h>#include <iostream>using namespace std;int main(){ double scores, numOfStudents, average = 0, highscore, sum = 0; string names; cout << "Hello, please enter the number of students" << endl; cin >> numOfStudents; do { cout << "Please enter the student's name:\n"; cin >> names; cout << "Please enter the student's...
Am I getting this error because i declared 'n' as an int, and then asking it to make it a double? This is the coude: #include "stdafx.h" #include <iostream> #include <fstream> #include <string> #include <algorithm> #include <vector> using namespace std; void sort(double grades[], int size); char calGrade(double); int main() { int n; double avg, sum = 0;; string in_file, out_file; cout << "Please enter the name of the input file: "; cin >> in_file; ...
Need help with a C++ program. I have been getting the error "this function or variable may be unsafe" as well as one that says I must "return a value" any help we be greatly appreciated. I have been working on this project for about 2 hours. #include <iostream> #include <string> using namespace std; int average(int a[]) { // average function , declaring variable int i; char str[40]; float avg = 0; // iterating in...
Fix my code, if I the song or the artist name is not on the vector, I want to user re-enter the correct song or artist name in the list, so no bug found in the program #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; class musicList{ private: vector<string> songName; vector<string> artistName; public: void addSong(string sName, string aName){ songName.push_back(sName); artistName.push_back(aName); } void deleteSongName(string sName){ vector<string>::iterator result = find(songName.begin(), songName.end(), sName); if (result == songName.end()){ cout << "The...
What did I do wrong with this C++ code? Assume that we don't need to ask users for the number of students. #include <iostream> #include <iomanip> using namespace std; int main() { float *grades; // a pointer used to point to an array int size; int count = 0; // track the number of grade/student float grade; // the grade of a student float average, total; // average grade and total grades //**************start your code here************************ cout<<"How many student grades...
The following is solved using C++ in Vocareum: In this problem, you will be prompting a student for grades and credits for courses taken. From that, you will calculate a GPA. This site: http://www.back2college.com/gpa.htm shows you how to calculate a GPA. Keep prompting the student if they want to add more courses. IMPORTANT NOTES! The course name is prompted for, but nothing is done with it. We are just using the grades A, B, C, D, and F so you...
C++ Assignment on Search and Sort for Chapter 8 Problem: Modify the student grade problem to include the following: • Write a Search function to search by student score • Write a Search function to search by student last name • Write a Sort function to sort the list by student score • Write a Sort function to sort the list by student last name • Write a menu function that lets user to choose any action he/she want to...
Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by...
C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...