Junaid Mahmud

Ranch Hand

Posts: 118

Norm Radder

Rancher

Posts: 2240

28

posted 1 year ago

What values does the program calculate? What are the correct values?

Do you have the formulas for doing the calculations? Can you get them from your professor?

One big problem I see with the code is the 2 and 3 letter variable names which make the code very hard to read and understand. Variable names should describe the values that they hold.

I am not correctly calculating the floor and wall space correctly.

What values does the program calculate? What are the correct values?

Do you have the formulas for doing the calculations? Can you get them from your professor?

One big problem I see with the code is the 2 and 3 letter variable names which make the code very hard to read and understand. Variable names should describe the values that they hold.

posted 1 year ago

I find this suspect

On line 1 you have floortype * floorspace, and on line 3 you have hardwood * floorspace. These don't seem consistent.

I would think that your floor type is a choice of menu options 1...n and doesn't necessarily represent the cost.

Your prompt for floortype doesn't give the user any clue as to what the possible options are and what they mean.

On line 1 you have floortype * floorspace, and on line 3 you have hardwood * floorspace. These don't seem consistent.

I would think that your floor type is a choice of menu options 1...n and doesn't necessarily represent the cost.

Your prompt for floortype doesn't give the user any clue as to what the possible options are and what they mean.

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

Junaid Mahmud

Ranch Hand

Posts: 118

posted 1 year ago

These are the values that are suppose to be inputted. (Below.) My professor said that the results 723.77 for the wall and 762.96 for the flooring. However my answers were completely different as I got 462 for the wall and 120 for the floor. If you could review these results please let me know if I am correct or wrong. Please let me know if my code HAS ERROS. Thanks!

o Room is 12.75 feet long, 11.25 feet wide, and 12 feet high

o Door is 1.95 feet wide by 10 feet high

o Window 1 is 2.5 feet wide by 5 feet high

o Window 2 is 6.8 feet wide by 7.2 feet high

o Bookshelf is 8 feet long by 6 feet high by 3 feet deep

o Cost per square foot for painting is $0.95

o Cost per square foot for carpeting is $1.25

o Room is 12.75 feet long, 11.25 feet wide, and 12 feet high

o Door is 1.95 feet wide by 10 feet high

o Window 1 is 2.5 feet wide by 5 feet high

o Window 2 is 6.8 feet wide by 7.2 feet high

o Bookshelf is 8 feet long by 6 feet high by 3 feet deep

o Cost per square foot for painting is $0.95

o Cost per square foot for carpeting is $1.25

posted 1 year ago

I'd suggest you to name variables properly, so you'd understand what each of them represents, and could check if you got formulae correct. For instance, what variable 'bookshlefp' (<- I copied/pasted) represents? lb * hb (<- how about those? what they represent?). No worries, I'd get confused too with such naming.

Can you write down the formulas you have been given how to perform the calculations?

Most likely.Junaid Mahmud wrote:my answers were completely different

...

Please let me know if my code HAS ERROS.

I'd suggest you to name variables properly, so you'd understand what each of them represents, and could check if you got formulae correct. For instance, what variable 'bookshlefp' (<- I copied/pasted) represents? lb * hb (<- how about those? what they represent?). No worries, I'd get confused too with such naming.

Can you write down the formulas you have been given how to perform the calculations?

Norm Radder

Rancher

Posts: 2240

28

posted 1 year ago

Take a paper and pencil and work out the values manually.

Copy and paste your computations here so we can see what you have done to find the values.

When you can manually compute the correct values, then work on fixing the code to compute the correct values.

results 723.77 for the wall and 762.96 for the flooring.

Take a paper and pencil and work out the values manually.

Copy and paste your computations here so we can see what you have done to find the values.

When you can manually compute the correct values, then work on fixing the code to compute the correct values.

Norm Radder

Rancher

Posts: 2240

28

Junaid Mahmud

Ranch Hand

Posts: 118

Junaid Mahmud

Ranch Hand

Posts: 118

Norm Radder

Rancher

Posts: 2240

28

posted 1 year ago

Can you write the the numbers and compute the two values to show what formulas are needed?

Since you know what the answers should be you should be able to manipulate the numbers to get the answers you were given.

Since you know what the answers should be you should be able to manipulate the numbers to get the answers you were given.

Junaid Mahmud

Ranch Hand

Posts: 118

posted 1 year ago

Hey I'm back! I had figured out what my mistake was. My professor assigned a new assignment in which I have to build off my previous assignment. In this new assignment I have to as the user the number of doors, windows, and bookshelves and then the length width and height depending on the item and number of items. This all has to be done in loops which I suck at and have no idea where to start. Thanks! here is the code.

posted 1 year ago
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

You might want to consider refactoring your code to make it more object oriented. Looking for nouns gives us a hint at what classes we might need.

Material with a field for name and cost. An abstract Item with fields for name, length, width, and height and methods getWallArea() and getFloorArea().

Subclasses of Item:

Room Shelf Window

From here, making a List<Item> can hold any number and combination of Rooms, Shelves, and Windows.

Your main user input loop then begins to look something like:

Subclasses of Item:

From here, making a List<Item> can hold any number and combination of Rooms, Shelves, and Windows.

Your main user input loop then begins to look something like: