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

7. Write a statement or statements that can be used in a Java program to dis- pl

ID: 3876813 • Letter: 7

Question

7. Write a statement or statements that can be used in a Java program to dis- play the following on the screen: 8. Write statements that can be used in a Java program to read your age, as entered at the keyboard, and display it on the screen. 9. Given a person's year of birth, the Birthday Wizard can compute the year in which the person's nth birthday will occur or has occurred. Write state- ments that can be used in a Java program to perform this computation for the Birthday Wizard. 10. Write statements that can be used in a Java program to read two integers and display the number of integers that lie between them, including the integers themselves. For example, four integers are between 3 and 6: 3, 4, 5, and 6.

Explanation / Answer

7. Write a statement or statements that can be used in a java program to display the following on the screen?

3

2

1

Solution:

System.out.println("3");

System.out.println("2");

System.out.println("1");

7. Write statements that can be used in a java program to read your age as entered at the keyboard, and display it on the screen?

Solution:

import java.util.Scanner;

Scanner sc=new Scanner(System.in);

System.out.println("enter your age");

int age=sc.nextInt();

System.out.println("Your age is"+age);

9 Given a person's year of birth, the Birthday Wizard can compute the year in which person's nth birthday will occur or has occured. Write statements that can be used in a java program to perform this computation for the Birthday Wizard?

Solution:

Import java.util.Scanner;

Scanner sc=new Scanner(System.in);

System.out.println("enter the year you were born");

int yearborn=sc.nextInt();

System.out.println("Enter birthday year which you want to check");

int checkyear=sc.nextInt();

System.out.println("You age in"+checkyear+"is"+(checkyear-yearborn));

10. Write statements that can be used in a java program to read two integers and display the number of integers that lie between them, including the integers themselves. For example four integers 3 and 6: 3,4,5,6

Solution:

import java.util.Scanner;

Scanner sc=new Scanner(System.in);

System.out.println("enter any two numbers");

int a=sc.nextInt();

int b=sc.nextInt();

for(int i=a;i<=b;i++)

System.out.println(i);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote