• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Homework for school

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

Billy Price 0867654327
Brad Smith 0873456789
Jean Murphy 0868876542
Jasmine Ahern 0867659871
Michael Smith 0831123457
Rose Harrison 0875437787

(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.

Search Term: Smi

Michael Smith 0831123457
Brad Smith 0873456789

Search Term: 086

Billy Price 0867654327
Jean Murphy 0868876542
Jasmine Ahern 0867659871


(3) Provide a means for the user to sort the contact information by the last name and first name of the contact, in ascending order.

Order by Full Name Ascending:

Jasmine Ahern 0867659871
Rose Harrison 0875437787
Jean Murphy 0868876542
Etc…

(4) As (3) above, but in last name and first name in descending order

Order by Full Name Ascending:

Michael Smith 0831123457
Brad Smith 0873456789
Etc…

 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm lost for first name ascending / descending loops
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And your question is?

Edit: I see you've added a question 1 second before I posted the above - excellent timing.
 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2nd part is methods
 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
about first name ascending/descending if output = more than 1
also any pointers in my coding ... we have limits
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Phillip O'Sullivan wrote:I'm lost for first name ascending / descending loops


In what way are you lost? You have a lot of code there, what is it supposed to do and what does it actually do?
 
Ranch Hand
Posts: 789
Python C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

(1) numJobLitres = calculateLitres(totalSquareMeters, METERS_PER_LITRE);

(2) totalJobHours = calculateJobHours(totalSquareMeters, HOURS_PER_SQUARE_METER);

(3) totalPaintCharge = calculatePaintCharge(numJobLitres, COST_PER_LITRE);

(4) totalLabourCharge = calculateLabourCharge(totalJobHours, LABOUR_PER_HOUR)

(5) totalJobCharge = totalPaintCharge + totalLabourCharge;

Note that the following constants have the respective values:

METER_PER_LITRE has a value of 14
HOURS_PER_SQUARE_METER has a value of 8
LABOR_PER_HOUR has a value of 20
COST_PER_LITRE has a value of 12

Finally,the application should display the following 5 painting estimate summary line items:

[i] Paint Job Specification: Number of Rooms: numRooms; Total Wall Space: totalSquareMeters square meters.

[ii] Cost per Litre: COST_PER_LITRE

[iii] Total Paint Cost: totalPaintCharge

[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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question is ... am I achieving / answering the questions
 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the 3rd part is Files where I would really appreciate some help
 
Marshal
Posts: 80282
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do really need some help with files as well
 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create a text file called CARDISSUES.TXT with the following contents:

FRAUD “I was never in France” Michael Madsen [Phone]
COMPLAINT “My wife stole my card” Michael Madsen [Phone]
LOST_CARD “Moulin Rouge ATM swallowed card” Ann Madsen [Phone]
COMPLAINT “Website Not Working” Nigel Landsman [Email]
LOST_CARD “Card Stolen” Catherine Sheehan [Phone]
COMPLAINT “Unfair Debt Recovery” James Smith [Email]

 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this mixed with an assignment we are doing
 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so at least I know there is a file .... maybe
 
Phillip O'Sullivan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
then I must convert the file to an array and output index [0] most used / least used
 
Campbell Ritchie
Marshal
Posts: 80282
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
All that thinking. Doesn't it hurt? What do you think about this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic