hts.StevenWood.com

Exercise 4-2-1

Home ] Up ] InitArray.java ] InitArray1.java ] InitArray2.java ] SumArray.java ] SumArray1.java ] SumArray2.java ] [ Exercise 4-2-1 ] Exercise 4-2-2 ] Exercise 4-2-3 ] Labs ] Rubric ][ Last Page ]

Exercise 4-2-1

Answer these questions in class or for homework.

  1. Declare a reference to life, a boolean array.  Solution
  2. Declare and allocate memory for a 1000 element integer array named price. Solution
  3. Declare an integer variable constant named ELEMENTS to have a value of 13. Solution
  4. Declare and allocate memory for a double array named numbers. The number of elements in the array is contained in a variable constant named ELEMENTS. Solution
  5. Initialize an array named small with the values of 23.34, 45.1, 75.4, and 12.3. Solution
  6. Use a loop to assign the values 0, 3, 6, 9, ..., 36 to the elements of an array named triples. Solution
  7. Create an int array named sample with 3 elements. Create a loop that will use keyboard input to ask for user input for the values of the 3 elements.
    e.g.
    Enter the value of element #0: 23
    Enter the value of element #1: -23
    Enter the value of element #2: 3

    Solution

  8. Use a loop to add up the values in the array in question 6, triples, and display the answer. Hint: use this code as a base for the loop. Solution
  9. Use an if statement inside a loop to add up the values in the array named triples that are divisible by 4. Display the answer. Hint: use modulus operatorSolution
  10. Make a menu driven program that will allow the user to do the following options:
    1. enter 10 elements into an array of 10 elements
    2. display the elements
    3. find the smallest value in the array

      Here is a section of code to help you get started with the menu driven program format.
      You are given a menu driven program that will repeat until you enter in the letter Q (or q).
      You have to fill in the 3 sections to complete tasks a, b, and c.


       
  11.  

 

Home ] Up ] InitArray.java ] InitArray1.java ] InitArray2.java ] SumArray.java ] SumArray1.java ] SumArray2.java ] [ Exercise 4-2-1 ] Exercise 4-2-2 ] Exercise 4-2-3 ] Labs ] Rubric ][Last Page]
All material on this site is copyright © 1997- by Steven Wood or as credited. All right reserved. Use of this site indicates you agreement with the  terms of use.
Send comments or questions to about this page.
Every attempt has been made to credit work under copyright. If there are any claims that copyright has been missed please contact the .
+SDG+