Ch.5 Practice Questions

# Int if x y or y z or z x printneither neither e55

• michaelsong234
• 5

This preview shows page 2 - 4 out of 5 pages.

int if x == y or y == z or z == x: print('neither') neither E5.5- import java.util.Scanner; public class Order { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter first digit number: "); String first = in.next(); System.out.print("Enter second single digit number: "); String second = in.next(); System.out.print("Enter the third single digit number: "); int third = in.nextInt(); System.out.println(); System.out.println("The numbers (" + first + " " + second + " " + third + ") are not in order. "); } E5.6- import java.util.Scanner; public class Order {

Subscribe to view the full document.

public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter first digit number: "); String first = in.next(); System.out.print("Enter second single digit number: "); String second = in.next(); System.out.print("Enter the third single digit number: "); int third = in.nextInt(); System.out.println(); System.out.println("The numbers (" + first + " " + second + " " + third + ") are not in order. "); } (Not sure for 5.6 — I don’t get the directions.) E5.7- import java.util.Scanner; public class P3_07 { public static void main(String[] args) { Scanner input = new Scanner(System.in); double n1 = input.nextDouble(); double n2 = input.nextDouble(); double n3 = input.nextDouble(); if ((n1 <= n2 && n2 < n3) || (n1 < n2 && n2 <= n3) || (n1 > n2 && n2 >= n3) || (n1 >= n2 && n2 > n3)) { System.out.println("In order"); } else { System.out.println("Not in order"); } input.close(); } } E5.10- public static void main (String [] args) { Scanner in = new Scanner(System.in); String water = ""; System.out.print("Enter a temperature: "); Double degrees = in.nextDouble();
• Fall '16

{[ snackBarMessage ]}

###### "Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

### 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