رد: ساعدوني في واجب لاب البرمجة
هذا هو السؤال ياليييييييييييييييييت تساعدوني
The following code is the solution of the "Lab Exercise 3-Largest Number” in sheet 5.
Scanner input = new Scanner( System.in );
int largest; // largest number
int number; // user input
int counter; // number of values entered
/* write code to get the first integer and store it in variable largest */
System.out.println( "Enter the number 1:" );
number = input.nextInt();
largest=number;
/* write code to initialize the number of integers entered */
counter=2;
/* write code to loop until 10 numbers are entered */
while(counter<=10)
{
/* write code to prompt the user to enter a number and read that number */
System.out.println( "Enter the number "+counter+":" );
number = input.nextInt();
/* write code to test whether the number entered is greater than the largest if so, replace the value of largest with the entered number */
if(number>largest)
largest=number;
/* write code to increment the number of integers entered */
counter++;
}
System.out.printf( "Largest number is %d\n", largest );
Q1:Modify the program to find the largest value of the x values entered.
read x from user. 0.5
|