Question: 2. Design a class SharePattern that has the following two fields: number_of_days_in_period and sharepoints_on_first_day. Class should have a constructor to set the values of these

2. Design a class SharePattern that has the following two fields: number_of_days_in_period and sharepoints_on_first_day. Class should have a constructor to set the values of these two fields. a method findFinalDaySharePoints that would return the share points on the final day of the period specified by the number_of_days_in_period field. The share points fluctuate in a similar way as described in Problem 1 of Homework #3. To test this class, write a HW4_Q2_YourStudentId_Demo class. In the main method of this class, the user will be asked to enter the number of days in the specified period and the share points on the first day. Then the object of SharePattern class is created using the constructor and the share point on the final day is obtained by calling the findFinalDaySharePoints method and displayed as shown below: For example, if a user enters as follows: Number of the days in the period: 11 Share points on the first day: 550 Then the program should display the following: The share points on the final day would be: 675

Here is Question 1 Hw 3 that it refers to:

1. Assume that the share points of a company fluctuate with a particular pattern in the New York Stock Exchange. It increases by 50 points every day in the first half of a given period and decreases by 25 points in the second half. If the number of days in a given period is odd, the first half is considered a day more than the second half. Write a Java program that will first ask users to enter the number of days in a given period and the share points on the first day. The number of days that is entered must not be less than 10 and more than 20. If it is not so, the user must be prompted to enter the input again with the following message: The number of days doesnt meet the required criteria, enter it again. The program should output a table showing the days and the share points on those days. For example, if a user enters as below: Number of days in the period: 11 Share points on the first day: 550 The program should output the following: Day Share Points 1 550 2 600 3 650 4 700 5 750 6 800 7 775 8 750 9 725 10 700 11 675

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!