ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 2 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 04 May 2017 My Price 8.00

Input-Processing-Output pattern

l

Objectives:

  • Create a complete program that follows the Input-Processing-Output pattern. 
  • Practice working with numerical data and performing calculations.
  • Develop test cases for a program and confirm that it produces the correct results.

Note: The "Boxes" sample program is an essential model for this assignment -- read its code carefully.

Instructions:

Task:  The Bricks & Mortar Construction Company builds strong foundations.  You are going to write a program for this company that computes the cost of a brick foundation designed according to customer specifications.

Specification:  

The foundations under consideration are rectangular in shape with a uniform height and uniform wall thickness.  A foundation is completely specified by four pieces of information:

  • Overall lengthin meters (m)
  • Overall width(m)
  • Wall height(m)
  • Wall thickness(m)

 

Here is the information the quotation needs to provide to the construction manager:

  • Overall areaof ground covered by the building that will go on this foundation (m2)
  • Enclosed area  -- the ground areainsidethe foundation walls (m2)
  • Total volumeof the foundation walls (m3) -- one way to calculate this is to multiply the "footprint" of the walls (the area of the part of the walls that touches the ground) times the height of the walls
  • Number of bricksneeded to build the foundation -- thevolumeof all of the bricks in the foundation divided by the volume of one brick
  • Number ofbags of mortarneeded to build the foundation.  You can calculate this based on the total volume of mortar in the foundation and the volume of one bag. 
  • Total massof the foundation (kg)
  • Materials costfor the foundation (the total cost for all the bricks and mortar)

Here is what you know about building foundations:

  • A brick measures 6 cm x 9 cm x 19 cm, has a mass of 2.3 kg, and costs $0.65.
  • One bag of mortar produces 0.025 m3of mortar with a mass of 43 kg at a cost of $7.25.
  • Mortar makes up 15% of the volume of a foundation (the rest is brick).
  • Note that you donotneed to worry about whether or not a discrete number of bricks can actually make up the desired wall thickness.  The clever mason will figure out how to build the wall!

User Interface:  Use the following guidelines to create an attractive and functional user interface of your own design:

  • Use clear prompts when requestinginputquantities from the user.
  • Format results appropriately, and be sure toshow unitsfor each quantity.

Program Structure:  Use the following program elements in a well-organized solution to this problem:

  • Usenamed constants(just variables that you never change) to represent facts that are thesame for allfoundations.
  • Organize your program with distinct sections forinput,processing, andoutput.
  • Usemeaningful namesfor all variables.

Comments:  

  • Make sure your code includescommentsat the beginning showing your name, yoursection number, the assignment number, the date, and a description of your program.
  • Include comments throughout the code (these are often called 'inline comments') that document what is being done and why.  Don't state the obvious -- focus on helping the reader understandwhysomething is being done.  (Hint: Thehardestway to include comments is to add them in last.  Honest!  Try organizing your thinking by including commentsas you write your program, right from the beginning!)

Testing:  Test your program to make sure everything works.  

  • Developat least 2test cases, calculate the correct results by hand, then confirm that your program gives the same results.  Note that the test data must make sense.  For example, the width of the wall must be greater than 2 times the thickness.
  • Document your testing: Add comments at the end of your code describing the test cases you used and the results you obtained.  Refer to the separate "Testing" note for more info and the 'Boxes' sample program for an example.
  • To help you confirm that you correctly understand how each of the results is calculated, here is a set of sample data and the correct answers:
    • Input data:  Length: 24 m, Width: 18 m, Height: 2 m, Thickness: 0.5 m
    • Results:
      • Overall Area: 432 m2
      • Enclosed Area: 391 m2
      • Total Volume: 82 m3
      • Number of Bricks: 67934
      • Bags of Mortar: 492
      • Total Mass: 177,404 kg
      • Materials Cost: $47,724

Tips: 

  • The "Boxes" sample program is an essential model for this assignment -- read its code carefully. 
  • Remember that each input quantity and each result needs its own variable.  Choose meaningful names for the variables and calculate the results in the order listed
   " Boxes" sample program below
  • # Boxes.py
# Demonstration of Input/Processing/Output
# Calculates some characteristics of a cardboard
# box given user specifications.

# Updated to change variable naming style.

# CSC 110
# 2/2/13


# CONSTANTS -- information we already know
CARDBOARD_COST_PER_SQUARE_METER = 1.25  # in dollars per sq. meter
CARDBOARD_THICKNESS = 0.5  # centimeters
SQ_CM_PER_SQ_METER = 10000.0  # conversion factor

    
# INPUT section -- get information from the user (floating-point numbers)
message = 'Please enter the 'height' of your box in centimeters.nThe ' 
          +'height is the distance between the ends of the box that open: '
height = float(input(message))
message = 'nNow enter the 'length' of your box in centimeters.nThe ' 
          + 'length is the longer of the two remaining dimensions: '
length = float(input(message))
message = 'nFinally, enter the last dimension of your box, ' 
          + 'nits 'width', also in centimeters: '
width = float(input(message))


# PROCESSING section -- perform calculations
    
external_volume = length * width * height;  # cubic centimeters
    
internal_volume = (length - 2 * CARDBOARD_THICKNESS) 
                  * (width - 2 * CARDBOARD_THICKNESS) 
                  * (height - 4 * CARDBOARD_THICKNESS)  # why 4?
                         
area_of_sides = (2 * length * height) + (2 * width * height)
       # 2 of each kind of "side"
       # Notice this could be reduced to:
       #   area_of_sides = 2 * (length + width) * height

area_of_flaps = (4 * length * (width / 2)) + (4 * width * (width / 2))
       # This could be reduced as well -- to what??

total_cardboard_area = area_of_sides + area_of_flaps  # area in square cm

box_cost = total_cardboard_area / SQ_CM_PER_SQ_METER 
           * CARDBOARD_COST_PER_SQUARE_METER
       # Notice this involves converting from square cm to square meters
       

# OUTPUT section -- show results
    
print('nnHere is your quotation:n')
print('Box length (cm.): ' + str(length))
print('Box width (cm.): ' + str(width))
print('Box height (cm.): ' + str(height))
    
print('External volume (cubic cm.): ' + str(external_volume))
print('Internal volume (cubic cm.): ' + str(internal_volume))
print('Cardboard area (square cm.): ' + str(total_cardboard_area))
                     
print('nYour cost per box is $' + format(box_cost, '.2f'))
print('nThank your for visiting the 'Boxes' page.')
print('We look forward to receiving your order!')



# Documented Test Results:

# This program was tested using the following inputs:
# height = 33
# length = 22
# width = 11

# The results produced were:
    
# Box length (cm.): 22
# Box width (cm.): 11
# Box height (cm.): 33

# External volume (cubic cm.): 7986.0
# Internal volume (cubic cm.): 6510.0
# Cardboard area (square cm.): 2904.0

# Your cost per box is $0.36
    
# These results agree with hand calculations.

Answers

(11)
Status NEW Posted 04 May 2017 02:05 AM My Price 8.00

-----------

Attachments

file 1493864117-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)