Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, this is Java. Please make it as simple as possible. This references things from Q1 I believe. This is THE CODE for Q1 :

Hi, this is Java. Please make it as simple as possible. This references things from Q1 I believe. This is THE CODE for Q1:

//import scanner

import java.util.Scanner;

//public class

public class HW4_Q1_001363109

{

//main class

public static void main(String[] args)

{

//variable declaration

int d, sp;

//scan inputs

Scanner in = new Scanner(System.in);

System.out.printf("Number of days in the period: ");

d = in.nextInt();

System.out.printf("Share points on the first day: ");

sp = in.nextInt();

int i = 1;

//display heading

System.out.printf("Day\tShare Points ");

//display share price on day 1st

System.out.printf("%d\t%d ",i, sp);

//loop for number of days times

for(i=2;i

{

if(i%2 == 0)

{

//increment share point by 50

sp = sp + 50;

//display outputs

System.out.printf("%d\t%d ",i, sp);

}

else if(i%2 != 0)

{

sp = sp - 25;

System.out.printf("%d\t%d ",i, sp);

//decrement share point by 25

}

}

} }//end of the program

--------------------------------------------------------------------------------

I ALREADY HAVE THE ANSWER TO Q1 I ONLY NEED Q2

ADD COMMENTS for Q2 PLEASE!! (//)image text in transcribed

2. Design a class SharePattern that has the following two fields: number_of_days_in_period and sharepoints_on_firstday. 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 I of this homework. To test this class, write a HW4 Q2 YourStudentld_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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

How were the HR functions affected by Hurricane Rita?

Answered: 1 week ago

Question

=+4 How does one acquire a global mindset?

Answered: 1 week ago

Question

=+2 How can the effectiveness of global virtual teams be improved?

Answered: 1 week ago