Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

CORAL PROGRAMMING Please, help me figure out where I messed up, this is my 2nd request. People are trying to help with Java which I

CORAL PROGRAMMING

Please, help me figure out where I messed up, this is my 2nd request. People are trying to help with Java which I don't understand since Coral is my first programming class.

5.12 LAB: User-Defined Functions: Adjust list by normalizing

When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. Define a function named getMinimumInt that takes an integer array as a parameter and returns the smallest value. Then write a main program that reads five integers as input, stores the integers in an array, and calls getMinimumInt() with the array as an argument. The main program then outputs the normalized array by subtracting the returned smallest value from all the values in the array.

Ex: If the input is:

30 50 10 70 65 

function getMinimumInt() returns 10, and the program output is:

20 40 0 60 55 

For coding simplicity, follow every output value by a space, even the last one.

Your program should define and use a function: Function getMinimumInt(integer array(?) userVals) returns integer minInt

This is what I got but I'm getting an error on Line 15: Variable declaration must be at top of function. Something above this line may not be a variable declaration

Function getMinimumInt(integer array(?) userVals) returns integer minInt integer i minInt=userVals[0] // Iterating the array and finding the min of the array for i = 1; i < userVals.size; i = i + 1 if userVals[i]

Function Main() returns nothing // integer array integer array(5) userVals // taking user input and storing it the array integer i for i = 0; i < userVals.size; i = i + 1 userVals[i]=Get next input - line 15 integer min min = getMinimumInt(userVals) // normalizing the array for i = 0; i < userVals.size; i = i + 1 userVals[i]=userVals[i]-min // printing the output Put userVals[i] to output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students explore these related Databases questions