Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.(Sorting three integer) Write a program that sort three integer. The integers

ID: 3621846 • Letter: 1

Question

1.(Sorting three integer) Write a program that sort three integer. The integers are entered from the input dialogs and sorted in variable num1, num2 and num 3 respectively the program sorts the number so that num1<= num2<= num3

 

2.(Checking a number) Write a program that prompts the user to enter an integer and checks whether the number is divisible by both 5 and 6 neither , or just one of them Here are some sample out puts10.30 and

 

10 is divisible by 5 or 6 but not both

 

30 is divisible by both 5 and 6

 

23 is not divisible by either 5 or 6

 

3.Write Algorithm and then a java program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive negative or zero.

 

 

4. Write an algorithem that asks the user to enter one of the following country abbreviataion (UAE,KSA,HKJ, ARE orSY the algorithm should then display the name of the country that corresponds with abbreviation entered(United Arab Emirates, Kingdom of Saudi Arabin,Hashemite Kingdom of Joran,Arab Republic of Egypt or Arab Republic of Syria) Display an error massage if an abbreviataion other than is listed is enterd. Change the Algorithm Written into aJava peogram using JCreator.

 

 

Explanation / Answer

Dear, 2) public class CheckNumber { public static void main(String [] args) { int number; //Create Scanner to obtain input from command window Scanner input=new Scanner(System.in); System.out.print("Input Number:"); number=input.nextInt(); if(number%5==0&&number%6==0) System.out.print(number+"is Divisible by both 5 and 6"); else if(number%5==0) System.out.print(number+" is divisible by 5 but not 6"); else if(number%6==0) System.out.print(number+" is divisible by 6 not 5"); else System.out.print(number +" Not divisible by either 5 and 6"); //exit program System.exit(0); } } 3) public class CheckNumber { public static void main(String [] args) { int number; //Create Scanner to obtain input from command window Scanner input=new Scanner(System.in); System.out.print("Input Number:"); number=input.nextInt(); if(number>0) System.out.println("Positive Number"); else if(number==0) System.out.print("Number is Equal to Zero"); else System.out.print("Negative"); //exit program System.exit(0); } }