Homework for school

Phillip O'Sullivan

Greenhorn

Posts: 21

posted 2 years ago

Past exam question ... expect it to be something similiar

Write a program (contactInfo.java) that has three parallel arrays. One of the arrays should hold people's first names, the other their last names, and the last array should hold their contact numbers. Here are the contact details in that order:

(1) Define and populate an array called firstNames that can contain the first names, another called lastNames to store the last names, and another called contactNumbers that contains the contact numbers. Define the arrays in the order as listed above.

(2) Provide a means for the user to search the arrays, and return the contact information that partially matches the beginning of any of the array contents. The keyword should be greater or equal to 3 characters in length.

That's a lot of code to slog through. Can you break your questions out of it? Parallel arrays aren't the first choice for something like that; maybe each entity could be an object instance and then you could have an array of those objects, if allowed.

Phillip O'Sullivan

Greenhorn

Posts: 21

posted 2 years ago

McDonald Paints are planning on releasing an Android smartphone app to their customers. The app will be a home painting estimator.

Write a prototype (paintCalc.java) that gives a java console version with the following input functionality:

- User is asked to enter the number of rooms (numRooms) to be painted
- For each room, the user is asked to enter the square metres (roomSquareMetres) for that room

With the above information, calculate the following figures using the syntax below:

[iv] Total Labor Cost based on estimate of totalJobHours hours of labour at LABOUR_PER_HOUR per hour = totalLabourCharge

[v] Estimated Total Cost: totalJobCharge

Phillip O'Sullivan

Greenhorn

Posts: 21

posted 2 years ago

These are 33% of a 2 hour exam

The frist question is about output:highest to lowest ... OK I have that in the last names ... but I also have 2 names "Smith" and first manes need to be sorted also
The 2nd question is ... is the method code readabel

We can only use what we are taught ... can't use array lists or anything ... I'm worried I will get done for system.out.printf("%s%s%s", a,b,c)

Phillip O'Sullivan

Greenhorn

Posts: 21

posted 2 years ago

I cheated as well in the methods as well using only "int" where I should have used doubles ... and decimal format

Phillip O'Sullivan

Greenhorn

Posts: 21

posted 2 years ago

The question is ... am I achieving / answering the questions

Phillip O'Sullivan

Greenhorn

Posts: 21

posted 2 years ago

the 3rd part is Files where I would really appreciate some help

Campbell Ritchie

Marshal

Posts: 56546

172

posted 2 years ago

I would knock 10% off for your using = in the middle of an expression.

I have also knocked some of the lengths of lines off. Look how you are supposed to break lines.

Are you sure you are supposed to multiply metres by metres per litre? Shouldn't it be divide?

Phillip O'Sullivan

Greenhorn

Posts: 21

posted 2 years ago

I would knock 10% off for your using = in the middle of an expression.

I have also knocked some of the lengths of lines off. Look how you are supposed to break lines

.... Plesae explain (highlight code)

Phillip O'Sullivan

Greenhorn

Posts: 21

posted 2 years ago

Also everyone says don't use parallel arrays ect ... IF I DON'T USE WHAT I HAVE BEEN TAUGHT ......... I FAIIL!!

then I must convert the file to an array and output index [0] most used / least used

Campbell Ritchie

Marshal

Posts: 56546

172

posted 2 years ago

Phillip O'Sullivan wrote: . . .

.... Plesae explain (highlight code)

Long lines (after correction) for example lines 14-18 and 31-32. You can see how the lines have been broken and indented so they can be seen all on one screen. You would have done it better yourself when writing the code.
Use of = inside an expression. There are very few places where you can get away with it; inside the heading of a while loop for example. In line 32 it makes for very confusing code. Particularly when you repeat it in line 39.

The multiple declarations in lines 14-18 are also poor style.

Tony Docherty

Bartender

Posts: 3271

82

posted 2 years ago

Phillip O'Sullivan wrote:Also everyone says don't use parallel arrays ect ... IF I DON'T USE WHAT I HAVE BEEN TAUGHT ......... I FAIIL!!

This is what I got

In the world of commercial programming parallel arrays are a terrible way to solve to problems like this however when you are first learning they are often used to get you used to concepts such as iterating over collections etc. So use them like you have been told to and file a note into the back of your mind to remind yourself to never do this is a real program.

BTW please don't fire off 1 line posts every minute or so as things pop into your mind. It makes it really difficult to help you because the target is constantly shifting. Occasionally we all submit a post and then think I should have also said x, y & z but this should be the exception and not the rule.