[Solved] CS1331-Homework 01 AGE CALCULATOR

$25

File Name: CS1331-Homework_01__AGE_CALCULATOR.zip
File Size: 320.28 KB

SKU: [Solved] CS1331-Homework 01 – AGE CALCULATOR Category: Tag:
5/5 - (1 vote)

Problem Description

Youve now been introduced writing a program in Java. This means you can write simple, but useful programs! Given your newfound skills, youve been hired by a company to calculate the age of customers! Youve been provided with a Java class, AgeCalculator that you need to fill in to the appropriate specifications.

Solution Description

For this assignment, you wont be expected to write your own class. Instead, well provide the class and you simply have to fill in the main method. Keep in mind that what you print out should match the defined output exactly. Deviation from what the output should be, even by a character or two, will result in lost points.

To start, save the following code in a file called AgeCalculator.java:

public class AgeCalculator { public static void main(String[] args) { // Do not modify the following line.int birthYear = Integer.parseInt(args[0]); // Part 1:// Part 2:}}

Part 1: Calculate the age

Inside of the main method, create a variable called age that can hold integers. Assign to age the age of the subject. Assume that someones age is the difference between 2019 and their birth year.

Part 2: Report the age

Once you calculate the age, its time to print it out. Output should be in the form:

This person is [age] years old!

Testing your app

In order to test your program, you can run java AgeCalculator [birth year] with some example year. For example,

java AgeCalculator 1998 prints out This person is 21 years old!

java AgeCalculator 2001 prints out This person is 18 years old! ___

Allowed Imports

To prevent trivialization of the assignment, you are not allowed to import any classes or packages.

Feature Restrictions

There are a few features and methods in Java that overly simplify the concepts we are trying to teach. For that reason, do not use any of the following in your final submission:

  • var (the reserved keyword)
  • exit

Collaboration

Collaboration Statement

To ensure that you acknowledge a collaboration and give credit where credit is due, we require that you place a collaboration statement as a comment at the top of at least one java file that you submit. That collaboration statement should say either:

I worked on the homework assignment alone, using only course materials.

or

In order to help learn course concepts, I worked on the homework with [give the names of the people you worked with], discussed homework topics and issues with [provide names of people], and/or consulted related material that can be found at [cite any other materials not provided as course materials for CS 1331 that assisted your learning].

Recall that comments are special lines in Java that begin with //.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS1331-Homework 01 AGE CALCULATOR
$25