01 - Dastrap - Java Review

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 01 - Dastrap - Java Review as PDF for free.

More details

  • Words: 435
  • Pages: 2
DASTRAP – Review of Java Programming Concepts May 28, 2009

I. Warm-ups – Variables, basics 1. Declare 1 char, 1 float, and 1 doubles. 2. Assign your group number to all 3 variables. 3. Output (use System.out.println) the sum of the float and double. 4. Write the whole code for HelloWorld.java, which outputs the string “Hello World!” 5. Write the println statement to output:

§ / \ / \ ” backslash

II. Operations 6. Declare 2 integers, assign the first integer with the value of 5, assign the square of this integer into the second integer. 7. Declare a double with an initial value of 5 and triple its value. 8. increment the double in #7 by 1. 9. declare an integer called groupNum, using your initial number assigned at the start of the class, compute for your group number and assign it into the variable groupNum. 10. given 3 doubles (a, b and c), compute for the 2 roots of of a quadratic equation using the

quadratic formula

use only 2 lines of code for this.

*hint: you may use Math.sqrt(num) to get the square root of num. III. Conditions 11. Declare 2 integers and assign any value to them. Write if statements for the following: (a) if the first integer is even, increment it by 1, (b) if the second integer is odd, decrement it by 1. 12. Given an integer, write an if statement that outputs yes if an integer is between 100 and 200. 13. Given an integer, write an if statement that outputs yes if an integer is NOT between 100 and 200. 14. Given an integer, write an if-else statement that outputs if it is positive, negative, or zero.

15. Given an integer, write a switch statement that outputs the number of days in the month that the given integer corresponds to. (Assume February has 28 days) IV. Loops 16. Create an infinite while loop that outputs your name. 17. Using a while loop, output all the multiples of 10 (from 10 to 100), then print their sum and average. 18. Using a do-while loop, compute for 5! (5 factorial). 19. Using a for loop, compute for the sum of all the odd numbers between 10 and 30. V. Take home 20. Given an integer n, draw * shaped as a diamond using loops *

*

***

***

*****

*****

***

*******

*

*****

n = 5

***

n = 7

* 21. Compute for compound interest. Given 3 values: a. Initial deposit b. Interest rate c. Number of years Then show the balance of the user every annum.

Related Documents

01 - Java Review V2
June 2020 1
Java 01
November 2019 2
Review Materi Java
April 2020 6
Review - Java In Practice
November 2019 12