Question

CHALLENGE ACTIVITY 3.4.2: Detect number range. Write an expression that prints "Eligible" if userAge is between...

CHALLENGE

ACTIVITY

3.4.2: Detect number range.

Write an expression that prints "Eligible" if userAge is between 18 and 25 inclusive.
Ex: 17 prints "Ineligible", 18 prints "Eligible".

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

import java.util.Scanner;

public class AgeChecker {

public static void main (String [] args) {

int userAge = 0;

userAge = 17;

if( /* Your solution goes here */ ){

System.out.println("Eligible");

}

else{

System.out.println("Ineligible");

}

return;

}

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;
public class AgeChecker {
public static void main (String [] args) {
int userAge = 0;
userAge = 17;
if( userAge >= 18 && userAge <=25 ){
System.out.println("Eligible");
}
else{
System.out.println("Ineligible");
}
return;
}
}

Output:

Ineligible

Do ask if any doubt. Please upvote.

Add a comment
Know the answer?
Add Answer to:
CHALLENGE ACTIVITY 3.4.2: Detect number range. Write an expression that prints "Eligible" if userAge is between...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • CHALLENGE ACTIVITY 3.5.1: Detect specific values. Write an expression that prints "Special number if specialNum is-99,...

    CHALLENGE ACTIVITY 3.5.1: Detect specific values. Write an expression that prints "Special number if specialNum is-99, 0, or 44. 1 import java.util.Scanner; 3 public class Find SpecialValue { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); int specialNum; specialNum - scnr.nextInt(); POSLOVOU if (/* Your solution goes here */) { System.out.println("Special number"); else { System.out.println("Not special number"); Run View your last submission

  • CHALLENGE ACTIVITY 3.11.1: Using boolean. D Assign is Teenager with true if kidAge is 13 to...

    CHALLENGE ACTIVITY 3.11.1: Using boolean. D Assign is Teenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign is Teenager with false. 1 import java.util.Scanner; 3 public class TeenagerDetector 1 public static void main (String [] args) { Scanner scnr = new Scanner(System.in); boolean isTeenager; int kidAge; D}]oll kidage = scnr.nextInt(); /* Your solution goes here */ Go USB if (isTeenager) { System.out.println("Teen"); else { System.out.println("Not teen"); 20 Run Feedback? CHALLENGE ACTIVITY 3.11.2: Boolean in branching statements. Write...

  • Feedback CHALLENGE ACTIVITY 3.8.1: Using boolean Assign is Teenager with true if kidAge is 13 to...

    Feedback CHALLENGE ACTIVITY 3.8.1: Using boolean Assign is Teenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign is Teenager with false. 1 import java.util.Scanner; 3 public class TeenagerDetector { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); boolean isTeenager; int kidAge; kidAge - scnr.nextInt(); /* Your solution goes here */ if (isTeenager) { System.out.println("Teen"); else { System.out.println("Not teen"); 19 20 ) ) Run Feed CHALLENGE ACTIVITY 3.8.2: Boolean in branching statements. - r

  • All JAVA code 6.2.2: Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints...

    All JAVA code 6.2.2: Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. Ex: printFeetInchShort(5, 8) prints: 5' 8" Hint: Use \" to print a double quote Sample program: import java.util.Scanner; public class HeightPrinter { /* Your solution goes here */ public static void main (String [] args) { printFeetInchShort(5, 8); System.out.println(""); return; } } 6.4.1: Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish...

  • CHALLENGE ACTIVITY 3.3.4: Multiple if statements: Print car info. Write multiple if statements. If carYear is...

    CHALLENGE ACTIVITY 3.3.4: Multiple if statements: Print car info. Write multiple if statements. If carYear is 1969 or earlier, print "Probably has few safety features." If 1970 or higher, print "Probably has seat belts." If 1990 or higher, print "Probably has anti-lock brakes." If 2000 or higher, print "Probably has air bags." End each phrase with period and newline. Ex: carYear = 1995 prints: Probably has seat belts. Probably has anti-lock brakes. import java.util.Scanner; public class CarFeatures { public static...

  • CHALLENGE ACTIVITY 4.8.1: Simon says Simon Says" is a memory game where Simon outputs a sequence...

    CHALLENGE ACTIVITY 4.8.1: Simon says Simon Says" is a memory game where Simon outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore Upon a mismatch, exit the loop using a break statement. Ex: The following patterns yield a userScore of 4 simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY 1 import java.util.Scanner; 3 public class...

  • Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for...

    Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for sample program: 3.5 import java.util.Scanner; public class HourToMinConv {    public static void outputMinutesAsHours(double origMinutes) {       /* Your solution goes here */    }    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       double minutes;       minutes = scnr.nextDouble();       outputMinutesAsHours(minutes); // Will be run with 210.0, 3600.0, and 0.0.       System.out.println("");    } } 2....

  • Write a while loop that prints all positive numbers that are divisible by 10 and less...

    Write a while loop that prints all positive numbers that are divisible by 10 and less than a given number n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90. import java.util.Scanner; public class PositiveLess {    public static void main(String[] args) {        Scanner in = new Scanner(System.in);        System.out.print("n: ");        int n = in.nextInt();        ...        while (...)        {           ...

  • Define a method printFeetinchShort, with int parameters numFeet and numinches, that prints using 'and' shorthand. End...

    Define a method printFeetinchShort, with int parameters numFeet and numinches, that prints using 'and' shorthand. End with a newline. Ex printFeetinch Short(5,8) prints: 5' 8" Hint Use l'to print a double quote. 1 import java.util.Scanner; public class Height Printer public static void printFeet InchShort(user feet." public static void main(String[] args) Scanner ser new Scanner(System.in); int userfeet: int user Inches; 13 userFeet - ser.nextInt(); user Inches - Sen.nextInt(); printFeet Inch Short(user Feet, user Inches); // Will be run with 5, 8),...

  • CHALLENGE ACTIVITY 7.16.1: Enter the output of the ArrayList ADT functions. Jump to level 1 Type...

    CHALLENGE ACTIVITY 7.16.1: Enter the output of the ArrayList ADT functions. Jump to level 1 Type the program's output import java.util.ArrayList; import java.util.Scanner; public class IntegerManager ( public static void printSize(ArrayList<Integer> numsList) System.out.println(numsList.size() + "items"); public static void main(String[] args) Scanner scnr = new Scanner(System.in); int currval; ArrayList<Integer> intList = new ArrayList<Integer>(); Input 123-1 printSize (intList); Output currval = scnr.nextInt(); while (currval >= 0) { intList.add(currval); currval = scnr.nextInt(); printSize (intList); intList.clear(); printSize (intList); 1 2 Check Next

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT