私はGPA計算機を作成しています。私はOR(||)関数でクレジットの入力が正しいかどうかをチェックする問題を抱えています(間違っていると、再度質問する必要があります)。また、成績の入力が「I」または「W」の場合、プログラムはその情報を使用すべきではありません(何もしないでください)。 手伝っていただきありがとうございます。ここ は、コードは次のとおりです。GPA電卓。 ORの問題と0で割る
// Include Statements
#include <iostream>
using namespace std;
//Program to calculate GPA
int main()
{
// Program made by Jose Luis Landivar
// Fall 2016
cout << ""<< endl;
cout << "The following program will calculate your GPA "<< endl<<'\n';
char grade;
int g = 1;
//variables for the algebraic operations needed
int credit = 0;
int totalcredit = 0;
int ptotal = 0;
double gpa, p = 1;
double count = 1;
double nclass;
string coursename, coursenumber;
cout << "Please enter the number of classes for the GPA calculator"<< endl;
cin >> nclass;
cout << ""<< endl;
while (count <= nclass) // While
{
//Information for the class
cout << "Please enter the course name for the class # "<< count << endl;
cin >> coursename;
cout << "Please enter the course number for the class # "<< count << endl;
cin >> coursenumber;
//Getting grades and credits from user
cout << "Enter the grade for the class # "<< count <<" (A,B,C,D,F,I,W)"<< endl;
cin >> grade;
if (grade == 'A' || grade == 'B' || grade == 'C' || grade == 'D' || grade == 'F' || grade == 'I' || grade == 'W')
{
// If for grades
if (grade == 'A')
{
g = 4;
cout << "Enter the number of credits for the class # "<< count <<" (1,2,3,4,5)"<< endl;
cin >> credit;
cout << ""<< endl;
if (credit == 5 || credit == 4 || credit == 3 || credit == 2 || credit == 1){
p = g * credit;
totalcredit = totalcredit + credit;
ptotal = ptotal + p;
}
else {cout << "Input is incorrect\n";
}
}
if (grade == 'B')
{
g = 3;
cout << "Enter the number of credits for the class # "<< count <<" (1,2,3,4,5)"<< endl;
cin >> credit;
cout << ""<< endl;
if (credit == 5 || credit == 4 || credit == 3 || credit == 2 || credit == 1){
p = g * credit;
totalcredit = totalcredit + credit;
ptotal = ptotal + p;
}
else {cout << "Input is incorrect\n";
}
}
if (grade == 'C')
{
g = 2;
cout << "Enter the number of credits for the class # "<< count <<" (1,2,3,4,5)"<< endl;
cin >> credit;
cout << ""<< endl;
if (credit == 5 || credit == 4 || credit == 3 || credit == 2 || credit == 1){
p = g * credit;
totalcredit = totalcredit + credit;
ptotal = ptotal + p;
}
else {cout << "Input is incorrect\n";
}
}
if (grade == 'D')
{
g = 1;
cout << "Enter the number of credits for the class # "<< count <<" (1,2,3,4,5)"<< endl;
cin >> credit;
cout << ""<< endl;
if (credit == 5 || credit == 4 || credit == 3 || credit == 2 || credit == 1){
p = g * credit;
totalcredit = totalcredit + credit;
ptotal = ptotal + p;
}
else {cout << "Input is incorrect\n";
}
}
if (grade == 'F')
{
g = 0;
cout << "Enter the number of credits for the class # "<< count <<" (1,2,3,4,5)"<< endl;
cin >> credit;
cout << ""<< endl;
if (credit == 5 || credit == 4 || credit == 3 || credit == 2 || credit == 1){
p = g * credit;
totalcredit = totalcredit + credit;
ptotal = ptotal + p;
}
else {cout << "Input is incorrect\n";
}
}
count = count + 1;
}
else {cout << "Input is incorrect\n";
}
}
//algebraic formulas
gpa = ptotal/totalcredit;
//output results
cout << "Your total number of credits is: " << totalcredit << endl;
cout << "Your GPA is: " << gpa << endl;
if (grade == 'I')
{
}
if (grade == 'W')
{
}
return 0;
}
"OR(||)関数に問題があります"ということで、どのような問題があるのでしょうか? –