Question
ITP100 Q1. Declare an integer array values[] of size 4 and populate it with numbers {2,4,5,6}. I need to write a program to find the
ITP100 Q1. Declare an integer array values[] of size 4 and populate it with numbers {2,4,5,6}. I need to write a program to find the sum of all elements of the array. Q2. Penny went shopping for shoes. She wants to calculate the sale price of a pair of shoes that is regularly $100.00 which is on sale at a 30% discount. She wrote a pseudocode as follow. Debug or correct the pseudocode for all errors. Write the corrected code below the original code and highlight it. regularPrice = 70.00 discount = 20 salePrice = regularPrice - (regularPrice * discount) Q3. Consider this code fragment below and answer the questions: int total = 0; int index = 0; for (index=0; index < =3; index++) total = total + i; index++; system.out.println(index) End For System.out.println(index); System.out.println(total); What will be the output of this program when it is executed by the computer? Q4. Function definition for minus() function is given below: number minus(number x, number y) { // this is the header of the function. number diff = 0 diff = x - y Display diff return diff } Answer the following questions:
1. What is being returned by the function minus(). 2. What the return type of the value being returned by the function. Q5. Write a function called minValue() which returns the minimum value of array elements. The function takes two input parameters as follows: aarray valuesN[] and the size of the array represented by variable length and computes the minimum value of the array elements. Q6. A function to validate a number to be within a range of 0 to 50 inclusive. The function must return the value of the validated number. Choose a name for the function. Decide what value will be returned by the function and its type and Decide the input parameter and it's type to the function. Q7. Declare two arrays named days[], and dailyRainFall[] of size 7. Ask the user to input values for days of the week and corresponding rain fall for all the SEVEN days. Write a program that will compute the total and average rainfall for the week. You must use a for or while loop to get the values in the arrays. Use another for or while loop to display rain Fall data in the following format: Day of the week daily rainfall Sunday 3 Monday 5 Tuesday 4 Wednesday 7 Thursday 4 Friday 3 Saturday 2 The total rain fall for the week is = xxx The average rain fall for the week is = xxx
Q8. Multiple choice questions. 8.1 The number of elements in the array int days[] = {12,3,4,5,6,7} is A. buses.length B. buses.length() C. buses.size D. buses.size() 8.2 What is the value of arr[4] if arr[] = {3,1,0,5,9} E. 3 F. 1 G. 0 H. 9 8.3 which index is the first element in the array arr[] = {3,1,0,5,9} I. 1 J. 0 K. 4 L. 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started