1 / 15

First Practical Quiz

First Practical Quiz. Third Year. 1. 2. 3. Create a program that outputs the following:. *** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

santos
Download Presentation

First Practical Quiz

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. First Practical Quiz Third Year

  2. 1 2 3

  3. Create a program that outputs the following: *** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *** * ** * * * *

  4. 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.

  5. Write a program that gets the area of a triangle whose base is 5 units and height is 4 units.

  6. 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 ______________.

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

  8. 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 ____.

  9. 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!!

  10. 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.

  11. 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

  12. 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****

  13. 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

  14. 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.

  15. Write a program that gets the average of the first ten even numbers, starting from 2.

More Related