السلام عليكم
فيه سؤال جاني كذا
Write a Java program that prompts the user to enter names of 10 students and their grades as one string separated with ‘,’. For each student, print out his name and classified grade.
**Note: use for loop and switch. **Hint: A (90-100) , B ( 80-89) , C (70-79) , D ( 60 – 69)
Sample Run:
Student1: Sara Alhazmi,88
Output:
Sara Alhazmi : B
Student2: Nada Alamri,95
Output:
Nada Alamri : A
(**Repeated 10 times)
وانا حليته كذا
import
java.util.*;public class
students{public static void main (String
args[]){;Scanner input= new Scanner
(System.in);int
f=10;for (int i=1 ; i<=f ;
i++){System.out.println("Student"+i+":");String s = input.nextLine();//s=name student and
gradString k
=s.substring(0,s.indexOf(","));//nameString
m = s.substring(s.indexOf(","));//graddouble grade
=Double.parseDouble(m)/10 ; int u =
Integer.parseInt("grade");switch
(u){case 10:case
9:System.out.println(k +":
A");case
8:System.out.println(k +":
B");case
7:System.out.println(k +":
C");case
6:System.out.println(k +":
D");default
:System.out.println(k +": f");}}}}لكن المشكلة يطلع لي الكمباير صحيح لكن الرن فيه مشكلة
وكذلك جاني هذا السؤال
Write a Java program that prompts the user to enter 10 positive integers and then Find the biggest value and number of its occurrences.
**Note : use While Loop.
Sample Run:
please enter 10 numbers:
1
2
46
1
0
5
46
46
6
27
The biggest value is: 46 and It occurs 3 times.
وانا حليته كذا
import java.util.*;public
class numbers{public
static void main(String
args[]){;Scanner input=new
Scanner (System.in);int
n=0;int
H=0;int
y=0;System.out.println("please Enter 10 numbers:");while
(n<10){int
f=input.nextInt();if (
f>y){y=f;n++;H=1;}else
if(y==f){H++;}}System.out.println("the
biggest value is: "+y+" and it is occurs
"+H+" times");}}هنا يطلع لي الكومابير صحيح والرن صحيح لكن يطلع لي لوب غير منتهي يعني ادخل ارقام كثيرة ولا يوقف !!
هل هناك مساعدة في حل هالمشكلتين ؟!
يرفع من قيمة الموضوع واهمية الرد