My code is giving me garbage out...I want them to caculate the credits by qualit
ID: 3625142 • Letter: M
Question
My code is giving me garbage out...I want them to caculate the credits by quality points but its giving me garbage out.. I think my format is wrong not sure heres my code:#include <iostream>
#include <iomanip>
#include <string>
//Function prototypes
using namespace std;
void printGpa(string, string, double, double);
//**here should I instead of listing separte just use one caculate gpa varible
//for getting my gpa caculated?
double caculateGpa1(int, double);
double caculateGpa2(int, double);
int main ( )
{
//Declare varaibles
string n1;
string n2;
int credits1;
int credits2;
double points1;
double points2;
double grade1;
double grade2;
//Intro
cout << " Students GPA Caculator" << endl;
cout << endl << endl;
// String of students last name
cout << " Please Enter The First Students Last Name ";
cin >> n1;
cout << " Please Enter The Second Students Last Name ";
cin >> n2;
//Input of Data for Quality Points
cout << " Please Enter " << n1 << " Quality Points ";
cin >> points1;
cout << " Please Enter " << n2 << " Quality Points ";
cin >> points2;
//Input of Total Credits Earned
cout << " Please Enter " << n1 << " Total Credits Earned ";
cin >> credits1;
cout << " Please Enter " << n2 << " Total Credits Earned ";
cin >> credits2;
cout << endl << endl;
//Call to functions Caculating GPA
double caculateGpa1(grade1);
double caculateGpa2(grade2);
//Call to funtions printname, gpa1, gpa2
printGpa(n1, n2, grade1, grade2);
system("PAUSE");
return 0;
// Vaule-returning function printname function
}
void printGpa(string n1, string n1, double grade1, double grade2)
{
cout << fixed << showpoint;
cout << setprecision(2);
cout << " " << n1 <<" GPA is " << grade1 << endl;
cout << " " << n2 <<" GPA is " << grade2 << endl << endl;
}
//Value-returning function definition
double caculateGpa1(int credits1, double points1)
{
double grade1;
gpa1 = points1 / credits1;
return grade1;
}
double caculateGpa2(int credits2, double points2)
{
double grade2;
gpa1 = points2 / credits2;
return grade2;
}
Explanation / Answer
// working now run
#include <iostream>
#include <iomanip>
#include <string>
//Function prototypes
using namespace std;
void printGpa(string, string, double, double);
//**here should I instead of listing separte just use one caculate gpa varible
//for getting my gpa caculated?
double caculateGpa1(int, double);
double caculateGpa2(int, double);
int main ( )
{
//Declare varaibles
string n1;
string n2;
int credits1;
int credits2;
double points1;
double points2;
double grade1;
double grade2;
//Intro
cout << " Students GPA Caculator" << endl;
cout << endl << endl;
// String of students last name
cout << " Please Enter The First Students Last Name ";
cin >> n1;
cout << " Please Enter The Second Students Last Name ";
cin >> n2;
//Input of Data for Quality Points
cout << " Please Enter " << n1 << " Quality Points ";
cin >> points1;
cout << " Please Enter " << n2 << " Quality Points ";
cin >> points2;
//Input of Total Credits Earned
cout << " Please Enter " << n1 << " Total Credits Earned ";
cin >> credits1;
cout << " Please Enter " << n2 << " Total Credits Earned ";
cin >> credits2;
cout << endl << endl;
//Call to functions Caculating GPA
grade1 = caculateGpa1(points1,credits1);
grade2 = caculateGpa2(points2,credits2);
//Call to funtions printname, gpa1, gpa2
printGpa(n1, n2, grade1, grade2);
// system("PAUSE");
return 0;
// Vaule-returning function printname function
}
void printGpa(string n1, string n2, double grade1, double grade2)
{
cout << fixed << showpoint;
cout << setprecision(2);
cout << " " << n1 <<" GPA is " << grade1 << endl;
cout << " " << n2 <<" GPA is " << grade2 << endl << endl;
}
//Value-returning function definition
double caculateGpa1(int credits1, double points1)
{
double grade1 = points1 / credits1;
return grade1;
}
double caculateGpa2(int credits2, double points2)
{
double grade2 = points2 / credits2;
return grade2;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.