This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

method help

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im stuck on writing an output method that does the following:
writes to a message dialog box the demin. of the room, the color of the paint, the # of cans of paint, and the total cost. Im brand new to methods and im kinda lost at this point. If you have any idea as to what some code for this method will look like please met me know. heres my methods so far:
code:
--------------------------------------------------------------------------------

public static int getSize (String caption) { String prompt = "Enter the " + caption + " of the room:"; String answer = JOptionPane.showInputDialog( null, prompt); int value = Integer.parseInt( answer ); return value;} public static String getPaintColor () { String prompt = "Enter the color of the room:"; String answer = JOptionPane.showInputDialog( prompt ); return answer; } public static int cansOfPaint(int height, int width, int length) { int surfaceArea = 0; surfaceArea += 2 * height * width; surfaceArea += 2 * height * length; surfaceArea += 2 * length * width; return (int) Math.ceil( surfaceArea / 350.0 ); }public static double totalCost ( int numberofCans, String nameofPaintColor) { double totalCost = 0; if (nameofPaintColor.equalsIgnoreCase("Green")) totalCost = 3.68 * numberofCans; if(nameofPaintColor.equalsIgnoreCase("Orange")) totalCost = 4.25 * numberofCans; if(nameofPaintColor.equalsIgnoreCase("Mauve")) totalCost = 3.69 * numberofCans; if(nameofPaintColor.equalsIgnoreCase("Eggshell")) totalCost = 4.25 * numberofCans; if(nameofPaintColor.equalsIgnoreCase("White")) totalCost = 3.25 * numberofCans; if (numberOfCans > 10) totalCost -= totalCost *.1; else if (numberOfCans > 5) totalCost -= totalCost*.06; return totalCost;}

--------------------------------------------------------------------------------


****This is what I have so far for the method. Add anything that you think will help to complete it cause this is where im getting stuck****

code:
--------------------------------------------------------------------------------

public static String outputmethod( ){ int length = getSize("length"); int width = getSize("width"); int height = getSize("height"); int numOfCans = cansOfPaint(length, width, height); }
 
todd stetter
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops lets try that again:How would I add another method whos task is to write a message to a mess. dialaog box the demin. of the room, the color of the paint, and the # of paint cans & the total cost? And also use the correct formatting!
Heres all my methods so far:


heres what I have so far. Im stuck after this. any ideas on code?
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
Java Code Review and Psychology
https://coderanch.com/t/714798/java/Java-Code-Review-Psychology
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!