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

(G6 - 7 points) Output the following lines of text exactly as they appear below:

ID: 3573420 • Letter: #

Question

(G6 - 7 points) Output the following lines of text exactly as they appear below: Fall Semester, 2016 ITEC 2140: Java Programming Fundamentals! My major is [fill in your program major] b. (G6 - 7 points) Prompt the user to enter a name and store in a String variable playerName. Prompt the user to enter number of points scored and store in a whole number variable score. Then print both the player name and the score to the console with a brief description of each. c. (G6 - 7 points) Determine Even or Odd Prompt the user to enter their lucky number and store in a variable myLuckyNum. If their lucky number is odd, then display “Your lucky number ? is odd.” (fill in their number for ?) Otherwise, display appropriate message for even. d. (G6 - 7 points) Determine Long or Short Prompt the user to enter their name and store in a variable myName. If their name has more than 6 characters, then display “? is a long name.” (fill in their name for ?) Otherwise, display an appropriate greeting using the name. Test cases: Kennedy >>> Kennedy is a long name. Kyle >>> Hello, Kyle. e. (G3 - 7 points) Compute the decimal number average of three integers. i. Prompt the user to enter three test grades as whole numbers and store in three variables. ii. Compute the decimal average of the three whole number test grades. iii. Display the average to the console. You must calculate the decimal average in the program. (Do NOT simply print the number you calculated with by hand!) ITEC 2140 Final Exam Spring, 2016 Page 2 of 3 2. Create a Computer class (G4 - 14 points) Write the definition of a class named Computer containing: a. An instance variable maker of type String, initialized to empty String. b. An instance variable numMegaBytesMemory of type int initialized to 0. c. An instance variable cpuSpeed of type double initialized to 0. d. An instance variable dualCore of type boolean initialized to false. e. In addition, your Computer class definition should provide an appropriately named "get" method and "set" method for each of these. f. A constructor with no-arguments that initializes the value of numMegaBytesMemory to 500 g. A constructor that accepts one String parameter and one double. The value of the String is used to initialize the value of maker. The double used to initialize the value of cpuSpeed. Note: you will not lose points for coding standards on this question, but try to keep it easy to read. 3. Write ComputerTester class (G4 - 7 points) ComputerTester should have a main method in it. Inside the main method: a. Create a Computer object named myLaptop using “HewlettPackard” and 3.8. b. Use the setter method to change the instance variable dualCore to true; c. Display the maker, numMegaBytesMemory, cpuSpeed and dualCore for myLaptop. d. Create a Computer object named myTablet using “MicroSoft Surface3” and 2.6 e. Set the sizeMemory of myTablet to 350. f. Display the maker, numMegaBytesMemory, cpuSpeed and dualCore for myTablet. 4. Write a complete program in file MagicArrayCount.java to do BOTH a & b below: a. Display Game player magic point maximum (G3, 5 - 7 points) You are designing a role playing game. In this program display the maximum magic points given the level of the player. Prompt the user for their player level. Then, display the maximum magic points for that level of player. The player's level determines the maximum magic points according to the following table: Level 1: 10 magic points Level 2: 15 magic points Level 3: 20 magic points Level 4: 25 magic points Level 5: 30 magic points Level 6: 35 magic points Here are some test cases: i. Level 1 player 10 ii. Level 2 player 15 iii. Level 6 player 35 ITEC 2140 Final Exam Spring, 2016 Page 3 of 3 b. Count Negative Numbers in Array (G5 - 7 points) In MagicArrayCount use an array of integers to compute and display the number of negative (less than zero) values in the array. a. Create the array of 5 integers. b. Use a loop to prompt the user to enter each of the 5 integers for the array c. Use a loop to count the negative numbers in the array d. Print the number of negative numbers in the array Here are some test cases: i. Array {-1, 0, 1, 2, 3} will print 1 ii. Array {9, -9, -3, 6} will print 2 iii. Array {1, 2, 3, 4, 5} will print 0

Explanation / Answer

Please follow the code and comments for description :

a)

CODE :

import java.util.Scanner; // requried imports

public class readData { // class

public static void main(String[] args) { // driver method
Scanner sc = new Scanner(System.in); // scanner class to get the data
System.out.print("Please Enter A Name : "); // prompt
String playerName = sc.nextLine(); // read data
System.out.print("Please Enter Number of Points Scored : "); // prompt
int score = sc.nextInt(); // read the data
System.out.println("The Players Name is : " + playerName + " and the Points Scored are : " + score); // message
}
}


OUTPUT :

Please Enter A Name : John
Please Enter Number of Points Scored : 55
The Players Name is : John and the Points Scored are : 55


b)

CODE :

import java.util.Scanner; // requried imports

public class lucky { // class

public static void main(String[] args) { // driver method
Scanner sc = new Scanner(System.in); // scanner class to get the data
System.out.print("Please Enter Your Lucky Number : "); // prompt
int myLuckyNum = sc.nextInt(); // read data
if(myLuckyNum % 2 == 0) { // check for the number
System.out.println("Your Lucky Number " + myLuckyNum + " is Even."); // message
} else {
System.out.println("Your Lucky Number " + myLuckyNum + " is Odd."); // message
}
}
}


OUTPUT :

Please Enter Your Lucky Number : 9
Your Lucky Number 9 is Odd.

Please Enter Your Lucky Number : 2
Your Lucky Number 2 is Even.


c)

CODE :

import java.util.Scanner;

public class name {

public static void main(String[] args) { // driver method
Scanner sc = new Scanner(System.in); // scanner class to get the data
System.out.print("Please Enter Your Name : "); // prompt
String myName = sc.nextLine(); // read data
if (myName.length() > 6) { // check for the length
System.out.println(myName + " is a Long Name."); // message
} else {
System.out.println("Hello, " + myName); // message
}
}
}

OUTPUT :

Please Enter Your Name : Kennedy
Kennedy is a Long Name.

Please Enter Your Name : Kyle
Hello, Kyle


d)

CODE :

import java.util.Scanner;

public class grades {

public static void main(String[] args) { // driver method
Scanner sc = new Scanner(System.in); // scanner class to get the data
System.out.println("Please Enter the 3 Test Grades : "); // prompt
System.out.println("Enter Grade 1 : ");
int g1 = sc.nextInt();
System.out.println("Enter Grade 2 : ");
int g2 = sc.nextInt();
System.out.println("Enter Grade 3 : ");
int g3 = sc.nextInt();
  
int avg = (g1 + g2 + g3) / 3; // calculate the grades
System.out.println("The Average of the Three Grades is : " + avg); // message
  
}
}


OUTPUT :

Please Enter the 3 Test Grades :
Enter Grade 1 :
56
Enter Grade 2 :
64
Enter Grade 3 :
82
The Average of the Three Grades is : 67


Hope this is helpful.