Lab1_2.java

# Lab1_2.java - import java.util.Scanner/Details Program will...

• Homework Help
• 2

This preview shows pages 1–2. Sign up to view the full content.

import java.util.Scanner; //Details: Program will calculate how many gallons Jake will use per mile. public class Lab1_2 { public static void main(String args [ ]) { //Variables double firstNumb = 60; double secondNum = 8; double thirdNum = 6; //Created Scanner Scanner input = new Scanner(System.in); //User Input Required System.out.println("Enter a number from 1-8: "); double inputValue = input.nextDouble(); double remainingAmount = (8 - inputValue); // Must enter a value between 1-8 Part 1 if (( inputValue >= 9)) { System.out.println("Error!"); } else if ((inputValue <= 0)) { System.out.println("Error!"); } else { System.out.println("Great number!"); } //Must enter a value between 1-8 Part 2 if (( inputValue >= 9)) { System.out.println("Try again. Enter a number between 1 - 8."); } else if ((inputValue <= 0)) { System.out.println("Try again. Enter a number between 1 - 8."); } else { System.out.println("\n"); System.out.println("If Jake uses " + inputValue + " gallon(s) in his fuel tank he \nwill only have " + remainingAmount +" gallon(s) left in his fuel \ntank since he only has an " + secondNum + " gallon fuel tank in his car."); System.out.println("\n"); System.out.println("If Jake drives " + firstNumb + " miles to

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Spring '17
• Computer Science, 1301, Imperial units, Gallon, System.out.println, Intro To Java

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern