Second Lab

27 Dec 2021 - 16:39 | Version 1 |

Learning Objective(s)

  1. Understand and use if statements
  2. Be able to use input/output
  3. Be able to write small programs
  4. Start to think about special cases

Overview of the Program

This lab has three separate programs. The can be found in chapter four of Let us Java → Question c, parts a, d, and g. Be sure to include proper comments in each program.

Specifics

  1. You may assume all numbers are integers.
  2. Include a separate section for each program in the testing report.

Program one

  1. The program should be called Profit
  2. If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he/she incurred.
  3. You should identify and use at least three different sets of data to properly test your program.

Program two

  1. The program should be called Ages
  2. If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to determine the youngest of the three.
  3. There could be at least 13 different types of data sets for testing but you only need to worry about six.

Program three

  1. The program should be called Triangle
  2. If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is isosceles, equilateral, scalene or right angled triangle.

Submission

  1. Create an empty zip folder.
  2. Place each program (.java file) in it
  3. Place your software development report in it. One report should cover all three programs. So most "sections" should have three parts, one for each program.
  4. Submit the zip folder on canvas

Optional improvements

Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor.
  1. Check for invalid input and reject it
  2. Handle all 13 possible test cases for program two.
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
This website is using cookies. More info. That's Fine