Starting from:
$30

$24

Software Design Laboratory Assignment 1 Solution

The goal of this assignment is to write a simple Java program to kick -start your Java programming skills. This assignment accounts for 8% of your final grade. First, install and configure your preferred Java IDE. If you choose to, you may work with a simple text editor like Notepad or TextEdit and compile and run your code from a command line terminal, but I do NOT recommend it.




Note: please do your own work, sharing and/or copying code and/or solution ideas with/from others will result in a grade of 0 and disciplinary actions for all involved parties. If you run into any problems and have done your best to solve them, please see me before/after class or e-mail me.




The assignment consists of two Java classes.




. This class is classified as a POJO class (see https://en.wikipedia.org/wiki/Plain_old_Java_object). It is a simple information and operations container class. The class contains the following members:



: a private variable of type.



: a private variable of type.



: a private variable of type.



: a private variable of type .



5)


: initializes


variables to


and numeric variables to
0
.
6)


:














accepts 4 parameters to initialize the 4 private variables.




















Setters and getters for all 4 private variables



, returns the price discounted by 15%



, returns the price discounted by 10%



, returns the age of the paining. This is simply the current year minus the value of the variable . You must extract the current year from the system. Do NOT hard-code the year (2019). Hint, use the classes form the Java library (e.g. class).
. This class is the driver class which has the task of testing the functionalities of the POJO class. The class contains the method only and performs the following steps.



Create an instance of type using the default constructor. Update the information in this instance as follows:





Mark Rothko


name
No. 6 (Violet, Green and Red)
price
186,000,000
year
1951



Use the Scanner class to prompt the user to enter values for , , , and . Before each prompt, display a message to the user to explain each required input. Remember to properly close the Scanner object



Create an instance of type using the non-default constructor and use the values entered in the previous step. The example in Figure 1 uses the following test values:





Paul Cezanne


Name
The Card Players
price
300,000,000
year
1892






Using the String formatting methods, format and print the information from the second instance such that:



The output is exactly as shown in Figure 2.



Each label is right aligned in a column of 24 characters
Floating-point values are printed using the thousands separator and two digits after the decimal point.
Integral values are printed as is.
Grades




Note: your code must compile and run in order for it be graded.










Class Paining
4






7




8






8




/
5






5






8


Class


10




Default constructor instance




















Scanner
6




4 prompts
8




Non-default constructor instance
5




Formatted print using String formatters
26






Figures:

























Figure 1: Prompts explain to the user what is required




(The black text is the prompt label while the green text is the input – highlighted by my Eclipse)

















































Figure 2: Formatted output

More products