Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following statement when responding to questions 1 and 2: Jim devel

ID: 664543 • Letter: C

Question

Consider the following statement when responding to questions 1 and 2:

Jim develops 5 Java applications a year. Joe develops 10 Java applications a year. Jim gets paid $5000.00 per application, but Joe gets paid $10000.00 per application.

1.) What type of equation would you create to determine how much either Joe or Jim makes separately? What equation is needed in Java (ignoring the $ symbol)? What data type is needed need for this equation?

2.) What type of equation would you create to determine the combined total of Joe and Jim's worth? What is the equation in Java? What would be an incorrect way of writing this equation (think parentheses)?

Explanation / Answer

// Jim 5 appliction $5000 per appln total $25,000

// Joe 10 applications 10,000 per appln. total $100,000

// 1. Type of equation for finding how much Jim makes separately:

// float rateOfJim;

// float totalOfJim;

// int numOfApplicationsByJim

// rateOfJim = 5000;

// numOfApplicationByJim = 5 // for Jim first

// float totalOfJim = numOfApplicationsByJim * rateOfJim   // Jim's

// totalOfJim = 5 * 5000 = 25000

// 2. Type of equation for finding how much Joe makes separately:

// float rateOfJoe;

// float totalOfJoe;

// int numOfApplicationsByJoe;

// rateOfJoe = 10000;

// numOfApplicationByJoe = 10 // for Joe next

// float totalOfJoe = numOfApplicationsByJoe * rateOfJoe   // Joe's

// totalOfJoe = 10 * 10000 = 100000

// data type needed is float

// 2. Combined total of Joe and Jim:

// float combinedTotal;

// combinedTotal = ( numOfApplicationsByJim * rateOfJim) + (

numOfApplicationsByJoe * rateOfJoe)
//******************************************************************
// Correct way of writing: ***********************************

combinedTotal = ( numOfApplicationsByJim * rateOfJim ) +

(numOfApplicationsByJoe * rateOfJoe )

// the correct combined total value is ( 5 * 5000 ) + ( 10 * 10,000)

= ( 25,000) + ( 100,000) = 125,000 = $125,000 = Correct value for combined total

// ***************************************************************
// InCorrect way of writing: ***********************************

combinedTotal = numOfApplicationsByJim * ( rateOfJim +

numOfApplicationsByJoe ) * rateOfJoe

// Reason for the incorrectness

// we had put the paranthesis in the wrong place

// paranthesis will change the priority of operation. Multiplication

( * ) has a higher priority over addition ( + )


// but if we missplace the parenthesis we get the following incorrect value for combined total

// 5 * ( 5000 + 10 ) * 10,000 = 5 * 5010 * 10,000 = 250500000 = incorrect combined total


// ***************************************************************


// the complete code is not asked for in the question so the code

below is just for knowledge

import java.lang.*;

import java.io.*;
class Developer

{

float salary;

// start of constructor for the developer class

    Developer(int numOfApplnPerYear, float rate, float total)

} // End of class Developer
public static void main(String[] args)

{

// instantiate the two objects - Jim and Joe of the class developer

Developer Jim = new Developer (NumOfApplnPerYear, Rate, Total);

Developer Joe = new Developer (NumOfApplnPerYear, Rate, Total);

}