In: Computer Science
Q1) Input your age and display what your age would be next year.
Submit screenshots from Marie.
My age is 21 and please provide clear screenshots.
Q2) Get your age and your friend's age
Determine who is the youngest
Determine who is the oldest
My age is 21 and my friend is 22
Marie is a stimulator and the program is Java. Kindly provide the work !!
1.
Code:
import java.util.*;
class ageNext
{
public static void main(String args[])
{
Scanner sc=new
Scanner(System.in);
int age;
System.out.print("Enter your age:
");
age=sc.nextInt();
System.out.print("Next year your
age will be: "+(age+1));
}
}
Code Screenshot:
Output Screenshot:
2.
Code:
import java.util.*;
class youngest
{
public static void main(String args[])
{
Scanner sc=new
Scanner(System.in);
int yourAge,friendAge;
System.out.print("Enter your age:
");
yourAge=sc.nextInt();
System.out.print("Enter your
friend's age: ");
friendAge=sc.nextInt();
if(yourAge<friendAge)
{
System.out.print("You are the youngest.");
}
else
{
System.out.print("Your friend is the youngest.");
}
}
}
Code Screenshot:
Output Screenshot: