Computers and Technology

1. Write a program that determines if the user can ride a rollercoaster. To ride the rollercoaster, you must be at least 42 inches tall. You must also be at least 9 years old.
The code is already written to ask the user how tall and old they are.
Write the code to determine if they can ride the rollercoaster.
If they can, print “Welcome aboard!”
If they cannot, print “Sorry, you are not eligible to ride”

import java. util. Scanner;

public class RideTheRollerCoaster
{
public static void main(String[] args)
{
Scanner input = new Scanner(System. in);

System. out. println("How tall in inches are you? " );
int height = input. nextInt();

System. out. println("How old are you? " );
int age = input. nextInt();

//Start your code here.

}
}

2. Write a program that asks the user for three strings.
Then, print out whether or not the first string concatenated to the second string is equal to the third string. Don’t worry about spaces at the beginning or ending of strings unless you want to! The code for the user to input the three strings is already written for you.
Here are a few sample program runs:
Sample Program 1:
First string? pepper
Second string? mint
Third string? peppermint
pepper + mint is equal to peppermint!
Sample Program 2:
First string? go
Second string? fish
Third string? donuts
go + fish is not equal to donuts!
import java. util. Scanner;
public class ThreeStrings
{
public static void main(String[] args)
{
Scanner input = new Scanner(System. in);

System. out. println("First String? ");
String first = input. nextLine();

System. out. println("Second String? ");
String second = input. nextLine();

System. out. println("Third String? ");
String third = input. nextLine();

//Start your code here.

}

}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:00, jairus34
We as humans write math expression in infix notation, e. g. 5 + 2 (the operators are written in-between the operands). in a computer’s language, however, it is preferred to have the operators on the right side of the operands, i. e. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix. write a program that takes an “infix” expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % (example infix expression: (7 - 3) / (2 + 2)postfix expression: 7 3 - 2 2 + /result: 1guidelines: 1. you will need to use stacks in three placesa. one for the parenthesis check [char stack]b. one during infix to postfix [char stack]c. one during evaluation [int stack]for a and b above, you can use same array and same push, pop method as both ofthem are char. but for evaluation you have int stack and you might consider to createanother push pop method to handle it. maybe push_int, pop_int, etc. or find otherstrategy to utilize existing push pop method2. you can create a function for obtaining operator priority. that function should take anoperator as input and return its priority as an integer. this function will you a lot andreduce repeated code3. during evaluation you will need to convert char into integer. example for single digit: char c = '5'; int x = c - '0';
Answers: 2
image
Computers and Technology, 22.06.2019 15:00, yeet74
I'm taking a class on how to make a movie, and it offers some apps that would be in the process. the thing is, i don't have any of those ha. if you have any tips on some apps i could use, that would be awesome. i don't have an iphone, so don't suggest any apps like imovie. i know that this is a weird question, but it would be super for me. : )
Answers: 2
image
Computers and Technology, 22.06.2019 16:00, eden1017
Why should characters such as / \ " ' * ; - ? [ ] ( ) ~ ! $ { } < > # @ & | space, tab, and newline be avoided in file names?
Answers: 2
image
Computers and Technology, 23.06.2019 02:30, noah2o2o
These factors limit the ability to attach files to e-mail messages. location of sender recipient's ability to open file size of file type of operating system used
Answers: 2
Do you know the correct answer?
1. Write a program that determines if the user can ride a rollercoaster. To ride the rollercoaster,...

Questions in other subjects: