SlideShare a Scribd company logo
1 of 5
Download to read offline
book is introduction of java programming, 10th edition for the last two questions
Solution
Problem1)
RandomNumbers.java
import java.util.*;
public class RandomNumbers {
public static void main(String[] args) {
//Declaring variables
int sum=0,square,randNum;
// Scanner object is used to get the inputs from the user
Scanner sc = new Scanner(System.in);
//Getting the maximum number entered by the user
System.out .print("Maximum Upto which number you want to generate Random numbers
from 0 :");
int max = sc.nextInt();
// creating the Random Class Object.
Random rand = new Random();
// Displaying the Random Numbers
System.out.println("The Random Numbers generated are:");
for (int i = 0; i < 10; i++) {
//Generating the random number
randNum=rand.nextInt((max) + 1);
System.out.print(randNum+ " ");
//calculating the sum
sum+=randNum;
}
//Displaying the results
System.out.println(" The Sum of Random numbers are :"+sum);
System.out.printf(" The Square Roor of Sum is :%.2f",Math.sqrt(sum));
}
}
__________________
Output:
Maximum Upto which number you want to generate Random numbers from 0 :100
The Random Numbers generated are:
39 11 43 73 10 66 26 35 54 37
The Sum of Random numbers are :394
The Square Roor of Sum is :19.85
____________
Problem2)
FibonacciNosRange.java
public class FibonacciNosRange {
public static void main(String[] args) {
int i = 1;
//This loop will display the fibonacci numbers
while (fibonacci(i) < 145) {
System.out.print(fibonacci(i) + " ");
i++;
}
}
//This method will calculate the fibanacci number
public static int fibonacci(int n) {
if (n == 0) {
return 0;
} else if (n == 1) {
return 1;
} else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
}
_____________________
output:
1 1 2 3 5 8 13 21 34 55 89 144
____________________
Problem4)
LeapYearsDisplay.java
public class LeapYearsDisplay {
public static void main(String[] args) {
//Declaring variables
int count=0;
//Displaying the leap years
for(int year=101;year<=2100;year++)
{
if(year%100==0 && year%400==0 || year%100!=0 && year%4==0)
{
System.out.print(year+" ");
//Count the no of leap years
count++;
}
if(count%10==0)
System.out.println();
}
//Displaying the number of leap year
System.out.println(" The number of leap years from 101 to 2100 is :"+count);
}
}
_______________________
Output:
104 108 112 116 120 124 128 132 136 140
144 148 152 156 160 164 168 172 176 180
184 188 192 196 204 208 212 216 220 224
228 232 236 240 244 248 252 256 260 264
268 272 276 280 284 288 292 296 304 308
312 316 320 324 328 332 336 340 344 348
352 356 360 364 368 372 376 380 384 388
392 396 400 404 408 412 416 420 424 428
432 436 440 444 448 452 456 460 464 468
472 476 480 484 488 492 496 504 508 512
516 520 524 528 532 536 540 544 548 552
556 560 564 568 572 576 580 584 588 592
596 604 608 612 616 620 624 628 632 636
640 644 648 652 656 660 664 668 672 676
680 684 688 692 696 704 708 712 716 720
724 728 732 736 740 744 748 752 756 760
764 768 772 776 780 784 788 792 796 800
804 808 812 816 820 824 828 832 836 840
844 848 852 856 860 864 868 872 876 880
884 888 892 896 904 908 912 916 920 924
928 932 936 940 944 948 952 956 960 964
968 972 976 980 984 988 992 996 1004 1008
1012 1016 1020 1024 1028 1032 1036 1040 1044 1048
1052 1056 1060 1064 1068 1072 1076 1080 1084 1088
1092 1096 1104 1108 1112 1116 1120 1124 1128 1132
1136 1140 1144 1148 1152 1156 1160 1164 1168 1172
1176 1180 1184 1188 1192 1196 1200 1204 1208 1212
1216 1220 1224 1228 1232 1236 1240 1244 1248 1252
1256 1260 1264 1268 1272 1276 1280 1284 1288 1292
1296 1304 1308 1312 1316 1320 1324 1328 1332 1336
1340 1344 1348 1352 1356 1360 1364 1368 1372 1376
1380 1384 1388 1392 1396 1404 1408 1412 1416 1420
1424 1428 1432 1436 1440 1444 1448 1452 1456 1460
1464 1468 1472 1476 1480 1484 1488 1492 1496 1504
1508 1512 1516 1520 1524 1528 1532 1536 1540 1544
1548 1552 1556 1560 1564 1568 1572 1576 1580 1584
1588 1592 1596 1600 1604 1608 1612 1616 1620 1624
1628 1632 1636 1640 1644 1648 1652 1656 1660 1664
1668 1672 1676 1680 1684 1688 1692 1696 1704 1708
1712 1716 1720 1724 1728 1732 1736 1740 1744 1748
1752 1756 1760 1764 1768 1772 1776 1780 1784 1788
1792 1796 1804 1808 1812 1816 1820 1824 1828 1832
1836 1840 1844 1848 1852 1856 1860 1864 1868 1872
1876 1880 1884 1888 1892 1896 1904 1908 1912 1916
1920 1924 1928 1932 1936 1940 1944 1948 1952 1956
1960 1964 1968 1972 1976 1980 1984 1988 1992 1996
2000 2004 2008 2012 2016 2020 2024 2028 2032 2036
2040 2044 2048 2052 2056 2060 2064 2068 2072 2076
2080 2084 2088 2092 2096
The number of leap years from 101 to 2100 is :485
_____________Thank You

More Related Content

More from FOREVERPRODUCTCHD

Write a program to convert a given INFIX into POSTFIX. Make sure .pdf
Write a program to convert a given INFIX into POSTFIX. Make sure .pdfWrite a program to convert a given INFIX into POSTFIX. Make sure .pdf
Write a program to convert a given INFIX into POSTFIX. Make sure .pdfFOREVERPRODUCTCHD
 
What quality control mechanisms should major accounting firms have i.pdf
What quality control mechanisms should major accounting firms have i.pdfWhat quality control mechanisms should major accounting firms have i.pdf
What quality control mechanisms should major accounting firms have i.pdfFOREVERPRODUCTCHD
 
What are three basic ethical principles for journalism Why are ethi.pdf
What are three basic ethical principles for journalism Why are ethi.pdfWhat are three basic ethical principles for journalism Why are ethi.pdf
What are three basic ethical principles for journalism Why are ethi.pdfFOREVERPRODUCTCHD
 
What are some of the different versions of UNIX® Why is it importan.pdf
What are some of the different versions of UNIX® Why is it importan.pdfWhat are some of the different versions of UNIX® Why is it importan.pdf
What are some of the different versions of UNIX® Why is it importan.pdfFOREVERPRODUCTCHD
 
Type in your own words In details, discuss the following questions.pdf
Type in your own words In details, discuss the following questions.pdfType in your own words In details, discuss the following questions.pdf
Type in your own words In details, discuss the following questions.pdfFOREVERPRODUCTCHD
 
Twice a first number decreased by a second number is 11. The first nu.pdf
Twice a first number decreased by a second number is 11. The first nu.pdfTwice a first number decreased by a second number is 11. The first nu.pdf
Twice a first number decreased by a second number is 11. The first nu.pdfFOREVERPRODUCTCHD
 
the largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdfthe largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdfFOREVERPRODUCTCHD
 
Suppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdfSuppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdfFOREVERPRODUCTCHD
 
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdfSummarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdfFOREVERPRODUCTCHD
 
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdfSOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdfFOREVERPRODUCTCHD
 
Step 12 The task is complete when the quota can be verified. Take a.pdf
Step 12  The task is complete when the quota can be verified.  Take a.pdfStep 12  The task is complete when the quota can be verified.  Take a.pdf
Step 12 The task is complete when the quota can be verified. Take a.pdfFOREVERPRODUCTCHD
 
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdfQUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdfFOREVERPRODUCTCHD
 
Python program with functions that extracts specific characters from.pdf
Python program with functions that extracts specific characters from.pdfPython program with functions that extracts specific characters from.pdf
Python program with functions that extracts specific characters from.pdfFOREVERPRODUCTCHD
 
Please answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdfPlease answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdfFOREVERPRODUCTCHD
 
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdfPlease help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdfFOREVERPRODUCTCHD
 
Know the different types of viruses which have a dsRNA genome A type.pdf
Know the different types of viruses which have a dsRNA genome  A type.pdfKnow the different types of viruses which have a dsRNA genome  A type.pdf
Know the different types of viruses which have a dsRNA genome A type.pdfFOREVERPRODUCTCHD
 
In what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdfIn what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdfFOREVERPRODUCTCHD
 
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdfIn the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdfFOREVERPRODUCTCHD
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfFOREVERPRODUCTCHD
 
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdfIf a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdfFOREVERPRODUCTCHD
 

More from FOREVERPRODUCTCHD (20)

Write a program to convert a given INFIX into POSTFIX. Make sure .pdf
Write a program to convert a given INFIX into POSTFIX. Make sure .pdfWrite a program to convert a given INFIX into POSTFIX. Make sure .pdf
Write a program to convert a given INFIX into POSTFIX. Make sure .pdf
 
What quality control mechanisms should major accounting firms have i.pdf
What quality control mechanisms should major accounting firms have i.pdfWhat quality control mechanisms should major accounting firms have i.pdf
What quality control mechanisms should major accounting firms have i.pdf
 
What are three basic ethical principles for journalism Why are ethi.pdf
What are three basic ethical principles for journalism Why are ethi.pdfWhat are three basic ethical principles for journalism Why are ethi.pdf
What are three basic ethical principles for journalism Why are ethi.pdf
 
What are some of the different versions of UNIX® Why is it importan.pdf
What are some of the different versions of UNIX® Why is it importan.pdfWhat are some of the different versions of UNIX® Why is it importan.pdf
What are some of the different versions of UNIX® Why is it importan.pdf
 
Type in your own words In details, discuss the following questions.pdf
Type in your own words In details, discuss the following questions.pdfType in your own words In details, discuss the following questions.pdf
Type in your own words In details, discuss the following questions.pdf
 
Twice a first number decreased by a second number is 11. The first nu.pdf
Twice a first number decreased by a second number is 11. The first nu.pdfTwice a first number decreased by a second number is 11. The first nu.pdf
Twice a first number decreased by a second number is 11. The first nu.pdf
 
the largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdfthe largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdf
 
Suppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdfSuppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdf
 
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdfSummarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
 
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdfSOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
 
Step 12 The task is complete when the quota can be verified. Take a.pdf
Step 12  The task is complete when the quota can be verified.  Take a.pdfStep 12  The task is complete when the quota can be verified.  Take a.pdf
Step 12 The task is complete when the quota can be verified. Take a.pdf
 
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdfQUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
 
Python program with functions that extracts specific characters from.pdf
Python program with functions that extracts specific characters from.pdfPython program with functions that extracts specific characters from.pdf
Python program with functions that extracts specific characters from.pdf
 
Please answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdfPlease answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdf
 
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdfPlease help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
 
Know the different types of viruses which have a dsRNA genome A type.pdf
Know the different types of viruses which have a dsRNA genome  A type.pdfKnow the different types of viruses which have a dsRNA genome  A type.pdf
Know the different types of viruses which have a dsRNA genome A type.pdf
 
In what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdfIn what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdf
 
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdfIn the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
 
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdfIf a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
 

Recently uploaded

Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 

Recently uploaded (20)

Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 

book is introduction of java programming, 10th edition for the last .pdf

  • 1. book is introduction of java programming, 10th edition for the last two questions Solution Problem1) RandomNumbers.java import java.util.*; public class RandomNumbers { public static void main(String[] args) { //Declaring variables int sum=0,square,randNum; // Scanner object is used to get the inputs from the user Scanner sc = new Scanner(System.in); //Getting the maximum number entered by the user System.out .print("Maximum Upto which number you want to generate Random numbers from 0 :"); int max = sc.nextInt(); // creating the Random Class Object. Random rand = new Random(); // Displaying the Random Numbers System.out.println("The Random Numbers generated are:"); for (int i = 0; i < 10; i++) { //Generating the random number randNum=rand.nextInt((max) + 1); System.out.print(randNum+ " "); //calculating the sum sum+=randNum; } //Displaying the results System.out.println(" The Sum of Random numbers are :"+sum); System.out.printf(" The Square Roor of Sum is :%.2f",Math.sqrt(sum));
  • 2. } } __________________ Output: Maximum Upto which number you want to generate Random numbers from 0 :100 The Random Numbers generated are: 39 11 43 73 10 66 26 35 54 37 The Sum of Random numbers are :394 The Square Roor of Sum is :19.85 ____________ Problem2) FibonacciNosRange.java public class FibonacciNosRange { public static void main(String[] args) { int i = 1; //This loop will display the fibonacci numbers while (fibonacci(i) < 145) { System.out.print(fibonacci(i) + " "); i++; } } //This method will calculate the fibanacci number public static int fibonacci(int n) { if (n == 0) { return 0; } else if (n == 1) { return 1; } else { return fibonacci(n - 1) + fibonacci(n - 2); } } } _____________________ output: 1 1 2 3 5 8 13 21 34 55 89 144 ____________________
  • 3. Problem4) LeapYearsDisplay.java public class LeapYearsDisplay { public static void main(String[] args) { //Declaring variables int count=0; //Displaying the leap years for(int year=101;year<=2100;year++) { if(year%100==0 && year%400==0 || year%100!=0 && year%4==0) { System.out.print(year+" "); //Count the no of leap years count++; } if(count%10==0) System.out.println(); } //Displaying the number of leap year System.out.println(" The number of leap years from 101 to 2100 is :"+count); } } _______________________ Output: 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 204 208 212 216 220 224 228 232 236 240 244 248 252 256 260 264 268 272 276 280 284 288 292 296 304 308 312 316 320 324 328 332 336 340 344 348 352 356 360 364 368 372 376 380 384 388 392 396 400 404 408 412 416 420 424 428
  • 4. 432 436 440 444 448 452 456 460 464 468 472 476 480 484 488 492 496 504 508 512 516 520 524 528 532 536 540 544 548 552 556 560 564 568 572 576 580 584 588 592 596 604 608 612 616 620 624 628 632 636 640 644 648 652 656 660 664 668 672 676 680 684 688 692 696 704 708 712 716 720 724 728 732 736 740 744 748 752 756 760 764 768 772 776 780 784 788 792 796 800 804 808 812 816 820 824 828 832 836 840 844 848 852 856 860 864 868 872 876 880 884 888 892 896 904 908 912 916 920 924 928 932 936 940 944 948 952 956 960 964 968 972 976 980 984 988 992 996 1004 1008 1012 1016 1020 1024 1028 1032 1036 1040 1044 1048 1052 1056 1060 1064 1068 1072 1076 1080 1084 1088 1092 1096 1104 1108 1112 1116 1120 1124 1128 1132 1136 1140 1144 1148 1152 1156 1160 1164 1168 1172 1176 1180 1184 1188 1192 1196 1200 1204 1208 1212 1216 1220 1224 1228 1232 1236 1240 1244 1248 1252 1256 1260 1264 1268 1272 1276 1280 1284 1288 1292 1296 1304 1308 1312 1316 1320 1324 1328 1332 1336 1340 1344 1348 1352 1356 1360 1364 1368 1372 1376 1380 1384 1388 1392 1396 1404 1408 1412 1416 1420 1424 1428 1432 1436 1440 1444 1448 1452 1456 1460 1464 1468 1472 1476 1480 1484 1488 1492 1496 1504 1508 1512 1516 1520 1524 1528 1532 1536 1540 1544 1548 1552 1556 1560 1564 1568 1572 1576 1580 1584 1588 1592 1596 1600 1604 1608 1612 1616 1620 1624 1628 1632 1636 1640 1644 1648 1652 1656 1660 1664 1668 1672 1676 1680 1684 1688 1692 1696 1704 1708 1712 1716 1720 1724 1728 1732 1736 1740 1744 1748 1752 1756 1760 1764 1768 1772 1776 1780 1784 1788 1792 1796 1804 1808 1812 1816 1820 1824 1828 1832 1836 1840 1844 1848 1852 1856 1860 1864 1868 1872 1876 1880 1884 1888 1892 1896 1904 1908 1912 1916
  • 5. 1920 1924 1928 1932 1936 1940 1944 1948 1952 1956 1960 1964 1968 1972 1976 1980 1984 1988 1992 1996 2000 2004 2008 2012 2016 2020 2024 2028 2032 2036 2040 2044 2048 2052 2056 2060 2064 2068 2072 2076 2080 2084 2088 2092 2096 The number of leap years from 101 to 2100 is :485 _____________Thank You