在JAVA中采用switch语句设计一个程序,对给定的学生成绩score评判其等级(优,良,中,及格,不及格)
2个回答
展开全部
楼上的,楼主要求的是Java。
import java.lang.*;
import java.util.Scanner;
public class test
{
public static void main(String[] args)
{
int score;
Scanner sc=new Scanner(System.in);
System.out.println("Please input the Score:");
score=sc.nextInt();
switch(score/10)
{
case 10:
case 9:System.out.println("优");break;
case 8:System.out.println("良");break;
case 7:System.out.println("中");break;
case 6:System.out.println("及格");break;
default:System.out.println("不及格");break;
}
}
}
import java.lang.*;
import java.util.Scanner;
public class test
{
public static void main(String[] args)
{
int score;
Scanner sc=new Scanner(System.in);
System.out.println("Please input the Score:");
score=sc.nextInt();
switch(score/10)
{
case 10:
case 9:System.out.println("优");break;
case 8:System.out.println("良");break;
case 7:System.out.println("中");break;
case 6:System.out.println("及格");break;
default:System.out.println("不及格");break;
}
}
}
展开全部
#include<stdio.h>
void main()
{
int score,i;
printf("Enter the Student's Score:\n");
scanf("%d",&score);
i= score/10;
switch( i )
{
case 10:
case 9: printf("A\n"); break;
case 8: printf("B\n"); break;
case 7: printf("C\n"); break;
case 6: printf("D\n"); break;
default:printf("E\n");
}
}
另一种:
#include <stdio.h>
void main()
{
char grade;
printf("Enter Grade:\n");
grade=getchar();
switch(grade)
{
case 'A': printf("85~100\n");
case 'B': printf("70~84\n");
case 'C': printf("60~69\n");
case 'D': printf("<60\n");
default : printf("ERROR\n");
}
}
再来一种:
#include"stdio.h"
void main()
{
int score;
printf("enter the student's score:\n");
scanf("%d",&score);
if(score>=90)
printf("A\n");
else
{ if(score>=80)
printf("B\n");
else
{ if(score>=70)
printf("C\n");
else
{ if(score>=60)
printf("D\n");
else
printf("E\n");
}
}
}
}
楼主慢慢学习。。。
void main()
{
int score,i;
printf("Enter the Student's Score:\n");
scanf("%d",&score);
i= score/10;
switch( i )
{
case 10:
case 9: printf("A\n"); break;
case 8: printf("B\n"); break;
case 7: printf("C\n"); break;
case 6: printf("D\n"); break;
default:printf("E\n");
}
}
另一种:
#include <stdio.h>
void main()
{
char grade;
printf("Enter Grade:\n");
grade=getchar();
switch(grade)
{
case 'A': printf("85~100\n");
case 'B': printf("70~84\n");
case 'C': printf("60~69\n");
case 'D': printf("<60\n");
default : printf("ERROR\n");
}
}
再来一种:
#include"stdio.h"
void main()
{
int score;
printf("enter the student's score:\n");
scanf("%d",&score);
if(score>=90)
printf("A\n");
else
{ if(score>=80)
printf("B\n");
else
{ if(score>=70)
printf("C\n");
else
{ if(score>=60)
printf("D\n");
else
printf("E\n");
}
}
}
}
楼主慢慢学习。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询