fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. float score;
  6.  
  7. // รับค่าคะแนนจากผู้ใช้
  8. cout << "กรุณากรอกคะแนน: ";
  9. cin >> score;
  10.  
  11. // ตรวจสอบคะแนนและแสดงเกรด
  12. if (score >= 80 && score <= 100) {
  13. cout << "เกรด: A" << endl;
  14. } else if (score >= 70 && score < 80) {
  15. cout << "เกรด: B" << endl;
  16. } else if (score >= 60 && score < 70) {
  17. cout << "เกรด: C" << endl;
  18. } else if (score >= 50 && score < 60) {
  19. cout << "เกรด: D" << endl;
  20. } else if (score >= 0 && score < 50) {
  21. cout << "เกรด: F" << endl;
  22. } else {
  23. cout << "คะแนนไม่ถูกต้อง!" << endl;
  24. }
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.02s 25844KB
stdin
Standard input is empty
stdout
#include <iostream>
using namespace std;

int main() {
    float score;

    // รับค่าคะแนนจากผู้ใช้
    cout << "กรุณากรอกคะแนน: ";
    cin >> score;

    // ตรวจสอบคะแนนและแสดงเกรด
    if (score >= 80 && score <= 100) {
        cout << "เกรด: A" << endl;
    } else if (score >= 70 && score < 80) {
        cout << "เกรด: B" << endl;
    } else if (score >= 60 && score < 70) {
        cout << "เกรด: C" << endl;
    } else if (score >= 50 && score < 60) {
        cout << "เกรด: D" << endl;
    } else if (score >= 0 && score < 50) {
        cout << "เกรด: F" << endl;
    } else {
        cout << "คะแนนไม่ถูกต้อง!" << endl;
    }

    return 0;
}