Calculate and output wall area

Assignment Help JAVA Programming
Reference no: EM131565456

Debugged with the instructions provided:

Guide to Pseudocode

Pseudocode is an intermediary step between reading a problem statement and writing the code to solve the problem. It serves as a blueprint for your program to guide you through, just like contractors start with a blueprint before building a house. Use your pseudocode as a tool to begin thinking about your program, but keep in mind it might not be the final solution to the problem. Pseudocode is written in a natural language using some programming keywords.

Consider the first example below: INCREMENT the number of apples in the basket by one Notice in the example that it fully describes, in natural language, what needs to be done in the program. When writing pseudocode, start at the beginning of what you need the program to do. Then work through, step by step, until reaching the end of what's required by the program in the problem statement. This is putting the problem in sequence.

For example, making a peanut butter sandwich: OBTAIN a plate OBTAIN two slices of bread OBTAIN a jar of peanut butter OBTAIN a knife Place the slices of bread on the plate Open the jar of peanut butter Spread peanut butter on one bread slice with the knife Place the empty slice of bread on top of the slice with peanut butter Serve There are several common keywords that get capitalized as they refer to actions taken in the program.

Those words include READ, WRITE, PRINT, DISPLAY, CALCULATE, SET, INCREMENT, and more. You can also show choices and loops in pseudocode. Just like in coding, when an item is nested inside another item, you indent that line of pseudocode. Below are three generic examples: IF condition THEN Include the first sequence ELSE Include the second sequence ENDIF WHILE condition Include the sequence ENDWHILE FOR loop parameters Include the sequence ENDFOR You can also use the keyword CALL to reference another algorithm written separately.

Now look at the following more complete examples of both good and bad pseudocode to get a general feel of how to write it. Bad Example (Vague and incomplete): function doProgrammingHomework(): Get things for homework Write the code correctly Finish the homework Bad Example (Too technical; does not follow natural language usage): function doProgrammingHomework(): getComputer(); openBlackboard(); for (var count = 0; count < problems.length(); count++) solve(); while (!compile) debug(); submit() shutDownComputer(); Good Example (Follows steps one at a time through the end of the algorithm): function doProgrammingHomework():

GET a computer OPEN the Blackboard module FOR each of the problems in the module Complete problem WHILE the problem does not compile Debug ENDWHILE Submit the assignment ENDFOR Shut down the computer Remember not to make your pseudocode too technical. You are not trying to write the code itself, just a plan as a stepping-stone after the initial problem to get your creative juices flowing.

code that needs to be debugged

import java.util.Scanner;
import java.lang.Math; // Note: Needed for math functions

PaintEstimator.java
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
double wallHeight = 0.0;
double wallWidth = 0.0;
double wallArea = 0.0;
double gallonsPaintNeeded = 0.0;
int cansNeeded = 0;

final double squareFeetPerGallons = 350.0;
final double gallonsPerCan = 1.0;

System.out.println("Enter wall height (feet): ");
wallHeight = scnr.nextDouble();

// Prompt user to input wall's width
System.out.println("Enter wall width (feet): ");
wallWidth = scnr.nextDouble();

// Calculate and output wall area
wallArea = wallHeight * wallWidth;
System.out.println("Wall area: "+wallArea+" square feet");

// Calculate and output the amount of paint in gallons needed to paint the wall
gallonsPaintNeeded = wallArea/squareFeetPerGallons;

System.out.println("Paint needed: " + gallonsPaintNeeded + " gallons");

// Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer
cansNeeded = (int) (gallonsPaintNeeded / gallonsPerCan);

if(gallonsPaintNeeded % gallonsPerCan > 0)
cansNeeded += 1;

System.out.println("Cans needed: " + cansNeeded + " can(s)");

return;
}
}

 

Reference no: EM131565456

Questions Cloud

Java programming assignment : Java programming assignment - Looking for someone to review my work and help me with the final few lines of unfinished code
What are the four parts of the cost hierarchy : What are the four parts of the cost hierarchy? Briefly explain each part, and contrast this cost hierarchy to the fixed-variable dichotomy
How many participants actually took part : What were the main findings or results of the research study?How many participants actually took part?
Discuss impact on proper placement and treatment planning : Describe in detail the 6 assessment dimensions of the ASAM patient placement criteria. Discuss their impact on proper placement and treatment planning.
Calculate and output wall area : IT 145 - Calculate and output the amount of paint in gallons needed to paint the wall and Calculate and output wall area
Analyze the projections for evolution in the future : Analyze the projections for evolution in the future and why this topic will remain a source of concern (consider advancements in research and technology).
Compute the ratios for both nike and under armor : Compute the ratios for both Nike and Under Armor for 2016 and fill in on the appropriate lines
How will the equal distribution of land and water affect : How will the equal distribution of land and water affect seasonal temperatures between the hemispheres relative to perihelion/solstice and aphelion/solstice?
Writing a program that implements an atm machine : Writing a program that implements an ATM machine. The interface to the program should be a Java GUI that looks similar

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd