Java Programming Assignment help

computer science

Description

Assignment 1: House Printer


CPSC 1150-005/006, Spring 2017

Instructor: A. Goldberg

Langara College


Preparation

Before attempting this assignment, it is absolutely imperative that you read the Assignment

Guide. There are instructions in that file that need to be followed in order to obtain full marks on

assignments. It is posted on D2L, inside a module entitled Course Information.

You are also expected to be familiar with the following textbook sections and lectures.

Textbook sections

 1.7-1.10

 2.2-2.8

Related lectures

 L1, L2

Introduction

The main purpose of this assignment is to get comfortable using Java and to learn the assignment

procedures for this course. It also covers basic input/output (I/O) and basic use of variables.

Before you start the programming exercises, make sure you have set up a directory to save your

files, as outlined in the Lab Guide.

1 Printing to the console

In this section, you will write a program called Asst1 which prints the following picture of a house

to the console:

. _____ .

/ \ _____ \

| | 0 0 |

| _ | __H__ |

Hint: To get a head start, copy the class and main method header from some other code. Make

sure to rename the class and file.

To get your output to look good, you will need to make sure it is monospaced. This means

that each printed character takes up the same amount of space horizontally. In some editors,

the output will not be monospaced by default.

 Hint: You may want to use multiple println statements to achieve this.

 Make sure your program compiles and runs properly before proceeding to the next section.


1


Assignment 1: House Printer


CPSC 1150-005/006, Spring 2017

Instructor: A. Goldberg

Langara College


2 Variables and input

In this section, you will modify your Asst1 program to first accept some information from the user

(number of residents, the total number of square feet, and total cost of the internet), and then calculate

the number of square feet per person, and the cost of internet per person. This information should

be printed to the console below the picture of the house. Do not erase the code from the previous

section. Make sure to compile early and compile often, so any errors don’t accumulate unstoppably.

The console should look something like this when the program is complete:

Please enter the number of residents in your house: 4

Please enter the area of the living space in square feet: 800

Please enter the total monthly cost of the internet : 42.60

. _____ .

/ \ _____ \

| | 0 0 |

| _ | __H__ |

Your house has 200 square feet per person.

Internet costs 10.65 per person.

1. To accept console input, you will first need to include a particular package at the top of your

source code. Do this now.

2. Declare the necessary variables.

3. Create a Scanner object.

4. Prompt the user separately for each required input, and using methods from the Scanner class,

save these inputs. Hint: You may find the Scanner methods nextInt() and nextFloat() to

be useful. To find more Scanner methods, or to see how to properly use these methods, look

up the Scanner class in the Java API online.

5. Calculate the per-person square footage and per person internet cost.

6. Display the house picture, and underneath, output your calculations to the console.

7. Make sure to close your Scanner at the end.

8. Make sure you fix any errors until the program compiles and runs properly.

Submission

The guidelines for how to document and submit your code are in the Assignment Guide. If you

do not follow these guidelines, you may receive a mark of 0 on this assignment. You are required

to submit:

 a properly commented source code file saved as Asst1.java

Instruction Files

Related Questions in computer science category