Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dlsclosure You will submit your file to an assignment that is given through Ms teams. Your filename should be ExI_yourstudentNumber.javo. Your main method should be

image text in transcribed

Dlsclosure You will submit your file to an assignment that is given through Ms teams. Your filename should be ExI_yourstudentNumber.javo. Your main method should be in the class with your student number [Ex1_yourStudentNuumber), Subrrissions made after the deadline will not be accepted, be sure to submit your work before the due date. Your code will be automatically controlled, 50 be sure to have the same class, method, variable names. Failure to do so may result in you receiving 0 from this exercise. All classes should be written to a single Java file. Your UML Class diagrams should be in pdf format. Exercises 1. The Stock Class); Write a class named Stock that contains; - Astring data field named symbol for the stock's symbol - A string data field named name for the stock's name - A double data field named previousclosingPrice that storess the stock price for the previous day - A double data field named currentPrice that stores the stock price for the current time - A constructor that creates a stock with the specified symbol and name - A method named getChangePercent(] that returns the percentage change from previousclosingPrice to currentPrice(). Draw the UML dlagram for the class. Write a test program (in a main method) that creates a Stock object with the stock symbol ORCL, the name Oracle Corporation, and the previous closing price of 34.5. Set a new current price 34.35 and display the price-change percentage. 2. [The ran class] Design a class named Fan to represent a fan. The class contains: - Three constants named SLOW, MEDIUM, and FAST with values 1,2 , and 3 to denote the fan speed - A private int data field named speed that specifies the speed of the fan (the default is SLOWI - A private booelan data field named on that specifies whether the fan is on ithe default is false) - A private double data field narned radius that speciiies the radius of the tari / the default is 5 ) - A string data field named color that specifies the color of the fan (the default is blue| - The accessor and mutator methods for all four data fields - A no-arg constructor that created a default fan. - A constructor that takes radius and color as parameters and creates a fan. - A method named tostring() that returns a string description of the fan. If the fan is on, the method returns the fan speed, color and radius in one combined string. If the fan is not on, the method retums the fan color and radius along with the string "fan is off" in one combined string Draw the UML diagram for the class and implement the class. Challenge Write a test propram that creates user defined amount of Fan objects. For each even indexed fan should be a default fan, for each odd indexed fan should have their radius increase by one and their fan wolor set as yellow. Be sure to use suitable constructor. Write a method that takes an arriy of Fans and increases the speed of ewery 3nd fan to next level, if it is already in FAST level, then it should be set to sLoW. Do these only if the fan is on. (bint: you con use setter method of speed dota field to encopstinte this logic)

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

Step: 3

blur-text-image

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago