I need to modify my program to use while and for loops and be able to do the following tasks:
a. A score of I on the project forces a mid-term grade of I. Notify the user to contact both the student and their advisor of the I grade.
b. For each student mid-term grade calculated , notify the user of the mid-term grade and if any of the grade elements is below a 75% and what the grade element is.


Here is what Ive gotten thus far...

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{double HW1,HW2,HW3,HW4,HW5,HW6,HW7,HW8,HW9,HW10,HWT,LG1,LG2,LG3,LG4,LGT,MTP,MTPG,MTE,MTEG,sum,;
 char MTPC,letter;

 cout<<"Please enter homework grade 1 (1-5); ";
 cin>> HW1;

 cout<<"Please enter homework grade 2 (1-5); ";
 cin>> HW2;

 cout<<"Please enter homework grade 3 (1-5); ";
 cin>> HW3;

 cout<<"Please enter homework grade 4 (1-5); ";
 cin>> HW4;

 cout<<"Please enter homework grade 5 (1-5); ";
 cin>> HW5;

 cout<<"Please enter homework grade 6 (1-5); ";
 cin>> HW6;

 cout<<"Please enter homework grade 7 (1-5); ";
 cin>> HW7;

 cout<<"Please enter homework grade 8 (1-5); ";
 cin>> HW8;

 cout<<"Please enter homework grade 9 (1-5); ";
 cin>> HW9;

 cout<<"Please enter homework grade 10 (1-5); ";
 cin>> HW10;

 cout<<"Please enter lab grade 1 (1-10): ";
 cin>> LG1;

 cout<<"\nPlease enter lab grade 2 (1-10): ";
 cin>> LG2;

 cout<<"\nPlease enter lab grade 3 (1-10): ";
 cin>> LG3;

 cout<<"\nPlease enter lab grade 4 (1-10): ";
 cin>> LG4;

 cout<<"\nPlease enter Mid-term project letter grade (A-F): ";
 cin>> MTPC;

 cout<<"\nPlease enter Mid-term Exam grade (1-55): ";
 cin>> MTE;

	MTPC=toupper(MTPC); 
 if(MTPC=='A')
	 MTP=95;
 else if(MTPC=='B')
     MTP=85;
 else if(MTPC=='C')
	 MTP=75;
 else if(MTPC=='D')
	 MTP=65;
 else if(MTPC=='F')
	 MTP=55;
 else if(MTPC=='I')
	 MTP=50;
//equations for final grade
HWT=(HW1+HW2+HW3+HW4+HW5+HW6+HW7+HW8+HW9+HW10)/50.*.15*100;
LGT=(LG1+LG2+LG3+LG4)/40.*.35*100;
MTPG=MTP*.25;
MTEG=(MTE/55.)*.25*100;

 sum=HWT+LGT+MTPG+MTEG;
if(sum>95)  //if-else statements, determines final grade
    letter='A';
else if(sum>85)
    letter='B';
else if(sum>75)
      letter='C';
else if(sum>65)  
      letter='D';
else if(sum>55)
     letter='F';
else if(sum>50)
	 letter='I';
 cout<<"\nyour final grade is: "<<letter<<endl;
 
system("pause");
return 0;
}

Dani AI

Generated

A compact plan to turn the current single-student program into a clear, loop-driven multi-student routine and to satisfy (a) the "I" project rule and (b) the per-component <75% reporting.

As showed, the calculations are already there; as suggested, arrays/vectors plus loops simplify input and sums. Use a while (or sentinel) to process each student and for loops to gather the 10 homeworks and 4 labs. Treat a project letter of I as an immediate midterm I and print a contact message for the student and advisor; skip further grade calculation for that student. For the <75% check, compute each component's raw percent (componentSum / componentMax * 100) before weighting, and report the component names that fall below 75.

Example structure (pseudocode):

while (next student) {
  for hw in homeworks read hw[i]
  for lab in labs read lab[i]
  read projectChar; projectChar = toupper(projectChar)
  if (projectChar == 'I') {
    print "Midterm: I. Contact student and advisor."
    continue
  }
  compute hwPct = sum(hw)/hwMax*100
  compute labPct = sum(lab)/labMax*100
  compute projPct = convertProjectLetterToPercent(projectChar)
  compute examPct = examScore/examMax*100
  weightedTotal = hwPct*hwWeight + labPct*labWeight + projPct*projWeight + examPct*examWeight
  determine midterm letter from weightedTotal
  print midterm letter
  if (hwPct < 75) print "Homework below 75%" (and same for lab, project, exam)
}

Troubleshooting tips: use std::vector and std::accumulate or explicit for loops; reset sums between students; use double for divisions to avoid integer truncation; validate inputs; centralize the letter→percent mapping in a small function; decide whether thresholds use >= or > and apply consistently. Splitting input, conversion, and reporting into small functions will make testing and unit checks easier.

loops and arrays (and other containers for that matter) are a match made in heaven. Put all the grades results in one or more array(s). Then use loops to do the calculations on lines 74, 75 and whereever else you need to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.