Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write java statements to do the following: Declare a String constant university

ID: 3873717 • Letter: W

Question

Write java statements to do the following: Declare a String constant university Name with "SHSU" as its initial value. i. ii. Declare a double variable named price; ii. Assign the value 2.99 to the variable price; iv. Declare an integer variable called count with an initial value of o; v. Declare a character variable named letterGrade; vi. Assign the character A to the variable letterGrade; vii. Declare a boolean variable named done; vili. Declare a Scanner variable named keyboardinput; create a Scanner object for the keyboard input and store the reference in the variable keyboardinput; ix. Among all above types, which are primitive types? Which are class types? x. Write an import statement to import the class Scanner; xi. Write an import statement to import the class JOptionPane Use Scanner method to read an integer from keyboard and store that value into the integer variable IDnumber; xii. xii. Use Scanner method to read a person's first name from keyboard and store the name into a String variable firstName

Explanation / Answer

Answers 1:

// i

final String universityName = "SHSU";

// ii

double price;

// iii

price = 2.99;

// iv

int count = 0;

// v

char letterGrade;

// vi

letterGrade = 'A';

// vii

boolean done;

// viii

Scanner keyboardInput = new Scanner(System.in);

// ix

class types: keyboardInput, universityName

prmimitive types: price, count, letterrGrade, done

// x

import java.util.Scanner;

// xi

import javax.swing.JOptionPane;

// xii

int IDnumber = keyboardInput.nextInt();

// xiii

String firstName = keyboardInput.next();

Answer a:

if(num1>=5.0&&num1<=7)

Answers b:

import java.util.Scanner;

public class Sample {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int num = scanner.nextInt();

if (num % 7 == 0)

System.out.println(num + " is divisible by 7");

else

System.out.println(num + " is not divisible by 7");

}

}

OUTPUT:

14

14 is divisible by 7

19

19 is not divisible by 7

Answer c:

BOTH first and second cases yields true

prints

This is the first case

This is the second case

Answer d:

import java.util.Scanner;

public class Sample1 {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int num = scanner.nextInt();

if (num > 90 && num < 100)

System.out.println("Excellent");

else if (num > 80)

System.out.println("Very good");

else if (num > 70)

System.out.println("Good");

else if (num > 60)

System.out.println("You pass");

else

System.out.println("You fail");

}

}

87

Very good

32

You fail

98

Excellent

75

Good

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote