PLEASE HELP....Visual Basic....... Write a program that requests a students firs
ID: 3679828 • Letter: P
Question
PLEASE HELP....Visual Basic....... Write a program that requests a students first name, last name and the numeric grades on three exams, and then uses a sub procedure to display the students name and semester grade (A, B, C, D, F,). A function procedure (called by the sub procedure) should be used to calculate the semester grade. The lowest grade should be dropped, the semester average should be rounded to the nearest whole number, and the semester grade should be assigned using the following criteria: 90-100(A), 80-89(B)
Explanation / Answer
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;
double input_score()
{
double score;
scanf("%lf",&score);
while(score < 0 || score > 100)
{
printf("Invalid Score, the valid range is 0 – 100 ");
printf("Enter the score again ");
scanf("%lf",&score);
}
return score;
}
double minimum( double a, double b, double c) // function to find lowest score
{
if( a < b && a < c) return a;
else if( b < a && b < c) return b;
else return c;
}
char gradeof (double average) // function to find grade
{
char grade;
if(average >= 90) grade = 'A';
else if(average >= 80 && average <=89.99) grade ='B';
else if(average >= 70 && average <=79.99) grade ='C';
else if(average >= 60 && average <=69.99) grade ='D';
else if(average < 60) grade ='F';
return grade;
}
int main()
{
char first_name[20];
char last_name[20];
double score;
while(1)
{
double score[3];
printf("Enter Student's First Name: ");
scanf("%s",&first_name);
printf("Enter Student's Last Name: ");
scanf("%s",&last_name);
printf("Enter Student's score for 1st subject: ");
score[0] = input_score();
printf("Enter Student's score for 2st subject: ");
score[1] = input_score();
printf("Enter Student's score for 3st subject: ");
score[2] = input_score();
double min = minimum(score[0],score[1],score[2]); // finding the lowest grade
double average = score[0] + score[1] +score[2]-min; // dropping the lowest grade
average = average/2;
average = round(average); // rounding the average
printf("Student Name: %s, %s ",first_name,last_name);
printf("Average Score: %.2lf ",average );
printf("Grade: %c ",gradeof(average));
char c;
printf("Calculate another student grade: (press Y for Yes, press N for No): ");
scanf(" %c",&c);
if(c == 'N' || c == 'n') return 0;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.