Time Limit: 1s
Memory Limit: 128MB
여러분은 다음과 같은 특징을 가지는 Stock 클래스를 만들어야 합니다.
여러분이 작성한 코드는 아래 샘플코드의 YOUR_CODE 부분에 들어가 컴파일 됩니다.
(The Stock class) Following the example of the Circle class in Section 9.2, design a class named Stock that contains:
■ A string 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 stores 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 changed from previousClosingPrice to currentPrice.
* Line 1 : id 문자열 (최대길이1,000)
* Line 2 : name 문자열 (최대길이1,000)
* Line 3 : 전날의 주식값 (1~1,000,000,000 사이의 실수)
* Line 4 : 오늘의 주식값 (1~1,000,000,000 사이의 실수)
* Line 1~3 : 샘플 출력 참조
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); Stock stock = new Stock(sc.nextLine(), sc.nextLine()); stock.setPreviousClosingPrice(sc.nextDouble()); stock.setCurrentPrice(sc.nextDouble()); System.out.printf("Prev Price: %.2f\n", stock.getPreviousClosingPrice()); System.out.printf("Curr Price: %.2f\n", stock.getCurrentPrice()); System.out.printf("Price Change: %.2f%%\n", stock.getChangePercent() * 100); } } YOUR_CODE
Naver Naver Corp. 392930 29911223
Prev Price: 392930.00 Curr Price: 29911223.00 Price Change: 7512.35%
JAVA2015 PE9.2