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

  A java program that reads the records

A java program that reads the records from the golf.dat file and displays them. It also displays the name of the player with the best (lowest) golf score.

  A java program that will prompt the user to input a file

Write a Java program that will prompt the user to input a file (document) in order to count the frequency of each word. This program will display the frequency of each word sorted alphabetically or by frequency (depending on the preference of the use..

  Design and implement recursive method findvalueunsortedarray

Design and implement a recursive method findValueUnsortedArray which takes two parameters: an unsorted array of integer values and an integer value which is looked for in the array.

  Design and implement a driver program testsocialgraph

Design and implement a driver program TestSocialGraph (in a separate source file TestSocialGraph.java) for testing the methods implemented in Part 1.

  Create a modular solution algorithm using pseudocode

Create a modular solution algorithm using pseudocode. Create a structure diagram/hierarchy chart grouping processes from the defining diagram into modules.

  Write java program that has at least the two methods

This method should take in a decimal number as an int and the base (or radix) you wish to convert that number to and return the String version of the decimal number in that base.

  Create an employee class

Create an Employee class. Items to include as data members are employee number, name, data of hire, job description, department, and monthly salary. The class is often used to display an alphabetical listing of all employs.

  What is the difference between statement

What is the difference between Statement and PreparedStatement interface?

  Your task is to design and implement a sorting

your task is to design and implement a sorting algorithmalgorithm that can sort nonnegative integers that fall within

  Print the date using alphabetic format.

Constructors use the same exception handling rules as methods: In a try block, include the parsing of the month and day substrings and other error-checking logic that will not work if parsing fails

  Write portions of java class that models a very simple clock

You will be writing portions of a Java class that models a very simple clock. You will also be provided with two different "front ends" that use this same class as a plug-in - a simple program that loops through the time for a full hour of time.

  Write java program to read present basic hourly wage

Write down a java program which will input 1. Read present basic hourly wage. Read in workers fist name and socond name.

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