Moderator: bigaun
HolyShadow wrote:มันเป็นการเขียนโปรแกรมแบบ OO คือต้องแยกไฟล์เป็นสามไฟล์คือ main .cpp Grade.h(header file) Grade.cpp(implement file)
แล้วรันมันถึงจะททำงานได้
#include<iostream>
using namespace std;
int main()
{
int quiz1=0,quiz2=0,midterm=0,final=0;
cout<<"Enter Quiz 1 Score : ";
cin>>quiz1;
cout<<"Enter Quiz 2 Score : ";
cin>>quiz2;
cout<<"Enter MidTerm Score : ";
cin>>midterm;
cout<<"Enter Final Score : ";
cin>>final;
/* calculate grade */
int total=0;
total = quiz1+quiz2+midterm+final;
/* show grade */
if( total >= 90 ){
cout<<"Total score is "<<total<<". Your grade is A. Congratulation, you are great!!! \n";
}//end if total >= 90
else{
if ( (total>= 80) && (total<= 89)){
cout<<"Total score is "<<total<<". Your grade is B. Good job!! \n";
}//end if ( (total>= 80) && (total<= 89))
else{
if ( (total>= 70) && (total<= 79)){
cout<<"Total score is "<<total<<". Your grade is C. Ok!!! \n";
}//end if ( (total>= 70) && (total<= 79))
else{
if ( (total>= 60) && (total<= 69)){
cout<<"Total score is "<<total<<". Your grade is D. You might have to retake this class again!! \n";
}//end if ( (total>= 60) && (total<= 69))
else{
if ( (total>= 60) && (total<= 69)){
cout<<"Total score is "<<total<<". Your grade is F. Sorry you Fail!! \n";
}//end if ( (total>= 60) && (total<= 69))
}
}
}
}
system ("pause") ;
return 0 ;
}
noo-mai-binpaibinma wrote:ใช่ค่ะ
แต่ปกติไม่มีเวลาคุยจริงๆจังๆๆเป็นเรื่องเป็นราว (เป็นข่าวหน้าหนึ่ง อะ!!ไม่เกี่ยว)
กับพี่ๆซักกะที
มาเจอกระทู้นี้ ก็เลยฝากคำถามไว้ที่บอร์ดน่ะค่ะ
โอเครค่ะ ขอบคุณมากที่อุตส่าห์มาตอบให้นะคะ
เดี๋ยวจะลองถามรุ่นพี่ดูละกัน
Return to Programming / Web-Programming
Users browsing this forum: No registered users and 0 guests