Question: 1- Given integer dollarAmount, write multiple if statements: If dollarAmount is greater than or equal to 7, output Buy a keychain. If dollarAmount is greater

1- Given integer dollarAmount, write multiple if statements:

If dollarAmount is greater than or equal to 7, output "Buy a keychain."

If dollarAmount is greater than 11, output "Buy a hat."

If dollarAmount is less than or equal to 1, output "Save money."

End with a newline.

Ex: If the input is 12, then the output is:

Buy a keychain. Buy a hat.

import java.util.Scanner;

public class RemainingAllowance { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int dollarAmount; dollarAmount = scnr.nextInt();

/* Your code goes here */

} }

2- Complete the expression so that userPoints is assigned with 0 if userBonus is greater than 25 (second branch). Otherwise, userPoints is assigned with 10 (first branch).

import java.util.Scanner;

public class Relational { public static void main (String [] args) { int userBonus = 0; int userPoints = 0; Scanner input = new Scanner(System.in); userBonus = input.nextInt(); // Program will be tested with values: 20, 24, 25, 26, 30, 35 if (/* Your code goes here */) { userPoints = 10; } else { userPoints = 0; }

System.out.println(userPoints); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!