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

Problem 2: President Age Ask the user to input his/her age. The check if the use

ID: 3751049 • Letter: P

Question

Problem 2: President Age Ask the user to input his/her age. The check if the user's age makes.him/her eligible to be a president of the United State of America. As..specified in the U.S. Constitution, a person must be aged 35 or over to be a president Problem 3: Profit vs. Lost Write a program that asks the user to input a product cost price and its selling price (two inputs). Then check if the seller makes a profit or loss from that product, in addition, to calculate the total profit or total loss rounded to 2 decimals digits.

Explanation / Answer

Problem 2 Java program

import java.util.Scanner;

public class Problemb2 {

public static void main(String[] arg)

{

int age;

Scanner sc = new Scanner(System.in);

System.out.println("Enter your Age");

age=sc.nextInt();

if(age>=25)

{

System.out.println("You are elgible to become president of USA");

}

else

{

System.out.println("You are not elgible to become president of USA");

}

}

}

Problem 3 Java program

import java.math.BigDecimal;

import java.util.Scanner;

public class problemb3 {

public static void main(String[] arg)

{

float cost;

float sell;

float result;

Scanner sc = new Scanner(System.in);

System.out.println("Input product Cost price");

cost=sc.nextFloat();

System.out.println("Input product Selling price");

sell=sc.nextFloat();

result= sell-cost;

result =round(result,2);

if(result>0)

{

System.out.println("Seller makes a profit of "+result);

}

else if(result<0)

{

System.out.println("Seller makes a loss of "+ Math.abs(result));

}

else

{

System.out.println("No profile, no loss");

}

}

public static float round(float d, int decimalPlace) {

BigDecimal bd = new BigDecimal(Float.toString(d));

bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);

return bd.floatValue();

}

}

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