Question

In: Computer Science

create a program that asks the user’s height What is your height? Use the input function...

create a program that asks the user’s height

  1. What is your height? Use the input function to ask this question
  2. If the answer to question 1 is greater than or equal to five, print "Yay! You can get on the rides alone"
  3. If the answer to question 1 is less than five and greater than four, print "You must be accompanied by an adult"
  4. Otherwise, print "Sorry you’re not allowed on the rides"

Solutions

Expert Solution

Code:

package assignment;

import java.util.Scanner;

public class Height {

   public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       System.out.println("What is your height? ");
       int n=sc.nextInt();
       if(n>=5) {//is greater than or equal to five
           System.out.println("Yay! You can get on the rides alone");
       }
       else if(n<5 && n>4) {// is less than five and greater than four
           System.out.println("You must be accompanied by an adult");
       }
       else {
           System.out.println("Sorry you're not allowed on the rides");
       }
   }

}

Note:***I hope your happy with my answer***If you have any doubts please comment me*****Thank you.......


Related Solutions

Create a Java application called ValidatePassword to validate a user’s password. Write a program that asks...
Create a Java application called ValidatePassword to validate a user’s password. Write a program that asks for a password, then asks again to confirm it. If the passwords don’t match or the rules are not fulfilled, prompt again. Your program should include a method that checks whether a password is valid. From that method, call a different method to validate the uppercase, lowercase, and digit requirements for a valid password. Your program should contain at least four methods in addition...
Write a program checkerboard3x3.cpp that asks the user to input width and height and prints a...
Write a program checkerboard3x3.cpp that asks the user to input width and height and prints a checkerboard of 3-by-3 squares. (It should work even if the input dimensions are not a multiple of three.) . Don't use function. Example 1: Input width: 16 Input height: 11 Shape: *** *** *** *** *** *** *** *** *** *** *** * *** *** * *** *** * *** *** *** *** *** *** *** *** *** *** *** * *** *** *...
Q1 Create a program that asks the user to input their budget. Then, it will ask...
Q1 Create a program that asks the user to input their budget. Then, it will ask the user to input each of their purchase until their entire budget is used up. What kind of loop do you think is the most appropriate? You don't have to create the entire program. Part of it has already been created for you (see code below). Note: Assume that the user always uses up their budget to the last cent and they don't over...
Using C++ Create a program that asks the user to input a string value and then...
Using C++ Create a program that asks the user to input a string value and then outputs the string in the Pig Latin form. - If the string begins with a vowel, add the string "-way" at the end of the string. For “eye”, it will be “eye-way”. - If the string does not begin with a vowel, first add "-" at the end of the string. Then rotate the string one character at a time; that is, move the...
IN JAVA Create a program that asks the user to input the day, high and low...
IN JAVA Create a program that asks the user to input the day, high and low temperature. Display the day, high, and low. Use a While Loop to enter all seven days of the week and high temperatures. Inside the While Loop, the program will count, total, and average the highs. The following will be displayed:                         Day: (variable)                         High: (variable)                         Count High: (variable)                         Total High: (variable)                         Average High: (variable) After the seven days and highs...
IN JAVA Create a program that asks the user to input the day, high and low...
IN JAVA Create a program that asks the user to input the day, high and low temperature. Display the day, high, and low. Use a While Loop to enter all seven days of the week and high temperatures. Inside the While Loop, the program will count, total, and average the highs. The following will be displayed:                         Day: (variable)                         High: (variable)                         Count High: (variable)                         Total High: (variable)                         Average High: (variable) After the seven days and highs...
Create a program that asks the user to input three numbers and computes their sum. This...
Create a program that asks the user to input three numbers and computes their sum. This sounds simple, but there's a constraint. You should only use two variables and use combined statements. You can use the output below as a guide. Please enter the first number: 4 Please enter the second number: 2 Please enter the third number: 9 The sum of the three numbers is: 15.
Create a JavaScript program that asks for the input of at least five words (a total...
Create a JavaScript program that asks for the input of at least five words (a total of 25+ characters) string from a user and performs the following functions to it: STRING METHODS Check to see if the string input meets the 25+ character limit. If it does not, send a message and ask for another string. Output the original string as it was entered onto the web page document. Output the original string in all lower case letters. Do not...
Create a program that asks the user for two positive integers. If the user's input for...
Create a program that asks the user for two positive integers. If the user's input for either integer is not positive (less than or equal to 0), re-prompt the user until a positive integer is input. You may assume that all inputs will be integers. Print out a list, ascending from 1, of all divisors common to both integers. Then, print out a message stating whether or not the numbers are "relatively prime" numbers. Two positive integers are considered relatively...
Create a BMI calculator that reads the user’s weight and height (providing an option for the...
Create a BMI calculator that reads the user’s weight and height (providing an option for the user to select which formula to use), and then calculates and displays the user’s body mass index. Also, display the BMI categories and their values from the National Heart Lung and Blood Institute: http://www.nhlbi.nih.gov/health/educational/lose_wt/BMI/bmicalc.htm (Links to an external site.) so the user can evaluate his/her BMI. Java Version
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT