Answered step by step
Verified Expert Solution
Question
1 Approved Answer
// use java 1. package week_1; import static input.InputUtils. doubleInput ; /** * To become a NASA astronaut, you need to be between 58 and
// use java
1.
package week_1; import static input.InputUtils.doubleInput; /** * To become a NASA astronaut, you need to be between 58 and 76 inches tall, so you * are not too tall to fit in the spaceship, but are tall enough to can reach all the controls. You also need to be able to swim at least 75 meters when you make a water landing on return to earth. Write a program to ask the user questions about their height and swimming ability, and then use conditional statements to determine if they have potential as a NASA astronaut. */ public class Question_3_NASA_Astronauts { public static void main(String[] args) { double height = doubleInput("How tall are you, in inches?"); double swimDistance = doubleInput("How far can you swim, in meters?"); boolean astronautPotential = checkAstronautQualifications(height, swimDistance); if (astronautPotential) { System.out.println("You have astronaut potential"); } else { System.out.println("Sorry, you don't meet the NASA qualifications."); } } public static boolean checkAstronautQualifications(double height, double swimDistance) { // TODO check the height, and swim distance. // return a boolean value representing whether the user meets these qualifications // TODO remove this line and replace with your own code return false; } }
//question 2
package week_1; import static input.InputUtils.yesNoInput; /** * USPS charges 49c to mail a standard, rectangular letter. USPS charges an extra 21c to mail a non-machinable letter, the type of letter that can't be processed by their mail-sorting machines. Rectangular letters can be processed by machine. Square, circular or other shaped letters can't be processed by machine. Letters must be flat to be processed by machine. Letters that are not flat (with bumps or have a curved shape) can't be processed by machine. Write a letter mailing price calculating program. Ask the user what shape their letter is - rectangular or not Ask the user if their letter is flat or not Calculate and display the cost to mail the letter. */ public class Question_4_Mail_Prices { // Some global constants. Use these variables in the calculateStampPrice method public final static int machinableLetterPrice = 49; public final static int nonMachinableSurcharge = 21; public static void main(String[] args) { boolean isRectangular = yesNoInput("Is the letter rectangular?"); boolean isFlat = yesNoInput("Is the letter flat?"); // Calculate price, in cents int price = calculateStampPrice(isRectangular, isFlat); System.out.println("Your letter will cost " + price + " cents to mail."); // Optional - if preferred, display the price as dollars and cents. } /* Calculate and return the price, in cents, to mail the letter. */ public static int calculateStampPrice(boolean isRectangle, boolean isFlat) { /* TODO Calculate and return the price, in cents, to mail the letter. * Use the two boolean variables isRectangle and isFlat to figure out the cost. * Use the machinableLetterPrice and nonMachinableSurcharge variables declared above. */ //TODO delete this line and replace with your own code return 0; // This is the wrong answer, but Java requires us to return something. } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started