Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

We have exercise classes.

So here sir im just answer this task with output codes


,lThis class , you will finish the follow questions on your computer.
Insert your answer into the following place of each question.
1、 You create a program to display prime numbers(page : 191 , 5.11)
Answer; Prime numbers up to 100:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

2、 you create a program to get a sum from 1 to 100.


Answer; the sum of numbers from 1 to 100 is 5050.
3、 You create a program to display 10 times “welcome to java”.
Answer: Welcome to Java
Welcome to Java
Welcome to Java
Welcome to Java
Welcome to Java
Welcome to Java
Welcome to Java
Welcome to Java
Welcome to Java
Welcome to Java

4、 You create a program to compare between x and y .and then you display the max value. To x and y ,you
design their values and type.
Answer: The maximum value between 10 and 20 is: 20 int x = 10 and int y = 20.

5、 You create a program to determine leap year.


Answer: Enter a year: 2024
2024 is a leap year.

6、 Describe the rules of the switch statement.(about page: 101 , you can find answer in 3.13 switch
statements. )
Answer: switch (day) { case 1: dayString = "Monday"; break; case 2: dayString = "Tuesday"; break; case
3: dayString = "Wednesday"; break; case 4: dayString = "Thursday"; break; case 5: dayString = "Friday";
break; case 6: dayString = "Saturday"; break; case 7: dayString = "Sunday"

-Day of the week: Wednesday

Day of Day of the week: Wednesday


the week: Wednesday

You might also like