150 likes | 275 Views
First Practical Quiz. Third Year. 1. 2. 3. Create a program that outputs the following:. *** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
E N D
First Practical Quiz Third Year
1 2 3
Create a program that outputs the following: *** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *** * ** * * * *
Using the modulus operator and division operator, Get a three digit number and output it’s hundreds, tens and ones. E.g. For the number 123, The hundreds is: 1. The tens is: 2. The ones is: 3.
Write a program that gets the area of a triangle whose base is 5 units and height is 4 units.
Write a program that declares two string variables firstName and surname, each with a value corresponding to your first name and your surname, respectively. After which, add another string variable which concatenates the two variables to form your full name. (Note: Full name should have appropriate space in between) OUTPUT: My first name is ________ My surname is _______ Therefore, my full name is ______________.
Write a program that declares an int variable Pi equals 3.14. Since this is not an int variable, convert it to it’s smallest integer by Casting. Then, multiple Pi by 3 and output the following: The product of 3 and the integer version of Pi is 9.
Write a program that verifies Java’s use of the PMDAS rule. Use the following expression: 2 + 3 x 5 + 7 – (4 + (4 x 3)) – 3 X 4. Output: Using PMDAS rule, the result of 2 + 3 x 5 + 7 – (4 + (4 x 3)) – 3 X 4 Is ____.
Write a program that declares an integer variable with value 5. Using the unary decrement operator, output the following countdown: OUTPUT: 5 4 3 2 1 BLAST OFF!!
Write a program that compares the relationship of Dora and Micah. Dora’s hotness factor is 95, while Micah’s hotness factor is 91. Output: Is Dora hotter than Micha? TRUE. Is Dora colder than Micha? FALSE. Is Dora’s hotness factor not equal to 95? FALSE.
Write a program that uses the AND operator to evaluate the average of Mike’s grades 90, 89, 84, and Kobe’s grades 87, 83, 85. Then, find out if they make it to the honor roll. They do if their average is equal to or greater than 85. Output: Mike’s average = _____. Kobe’s average= _____. Do they make it to the honor roll? TRUE
Write a program that declares four character integers, all with the value “P”, “E”, “A”, “C”.. Then, add all these character integers to spell out the word peace. Output: ****PEACE****
Using the ternary conditional operator status = (BOOLEANexp1)?exp2:exp3; And the modulus operator, Determine if 50 is divisible by 2, 3, 5, 7 and 10. Output: 50 is divisible by 2 50 is not divisible by 3 50 is divisible by 5 50 is not divisible by 7 50 is divisible by 10
Using the ternary conditional operator status = (BOOLEANexp1)?exp2:exp3; Write a program which determines if a person gets paid zero or full salary of 200 pesos, depending on his work hours. If his work hours exceeds 5 hours he gets paid. Given, he worked for 6 hours. Output: Since he worked for 6 hours, he gets a salary of 200 pesos.
Write a program that gets the average of the first ten even numbers, starting from 2.