Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This Lab contains two parts. Each part is it's own class file. The first part (Part I) is simply to create a Java program which

image text in transcribed
image text in transcribed
image text in transcribed
This Lab contains two parts. Each part is it's own class file. The first part (Part I) is simply to create a Java program which calculates the answers to the function practice we did yesterday in class (Lab3_Part1.java). The second part is about "generalizing" the code in Lab 2 a bit further to eliminate redundant for loops -- where identical "inner loops" appear in multiple places -- by adding a few additional methods which encapsulate the loop behavior (Lab3_Part2.java). Examples are attached to this Lab. Part I: (Class name: Lab3_PartI) 1. Create valid Java functions definitions for each of the following (see attached example): fun1 (x) = 2 * x fun2(x, y, z) = x + y + z fun3 (x, y) = fun1 (2 * x) + y fun4 (x, y) = fun3 (x, fun1 (y)) 2. Create a "main" method which prompts the user for the values to pass to each of the functions (as per the "worksheet", see the attached example). Assuming the USER has entered the values for x, y, and z are calculated as follows. a = fun1 (2) b = fun2 (x,y,z) c = fun3 (x,y) d = fundx 2. Create a "main" method which prompts the user for the values to pass to each of the functions (as per the "worksheet", see the attached example). Assuming the USER has entered the values for x, y, and z are calculated as follows. a = fun1 (z) b = fun2 (x,y,z) c = fun3 (x,y) d = fun 4 (x,y) e = fun3 (x, fun1 (x)) 3. Display the results. Assuming the user entered 1,2, and 3 for the value of x, y, and z, the output for would look like this (see the attached example): fun1(1) = 2 fun2 (1,2,3) = 7 fun3 (1,2) = 6 fun4 (1,2) = 8 fun3(1, fun1 (1)) = 6 Part II: (Class name: Lab3_PartII) 1. This part is intentionally a bit less specific as the objective is for you to minimize the unnecessary redundancy in Lab2 by "generalizing" the loop redundancy - where possible - by encapsulating the "inner loops" (within the shape drawing functions) into their own functions. Just like back in Labl, some functionally will heunime enough to keep everything fun1 (1) = 2 fun2 (1,2,3) = 7 = 6 fun3 (1,2) fun4 (1,2) = 8 fun3 (1, fun1 (1)) = 6 Part II: (Class name: Lab3_PartII) 1. This part is intentionally a bit less specific as the objective is for you to minimize the unnecessary redundancy in Lab2 by "generalizing the loop redundancy - where possible - by encapsulating the "inner loops" (within the shape drawing functions) into their own functions. Just like back in Labl, some functionally will be unique enough to keep everything together in a single function, other places may have the same reoccurring structures which could be broken out into their own slapper functions. In short: Remove the inner-loops from your Lab2 Solution and, WHERE POSSIBLE, replace them with calls to functions/methods, passing any necessary parameters. (It's best to see the attached example for an example) And yes... as is true with MOST REAL-WORLD PROGRAMMING, this part is a bit more "subjective" and there is not "one correct way" of breaking things apart

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

Step: 3

blur-text-image

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions