2015. 8. 9. 23:49, C#/Head First C# Practice
[설명]
이동거리를 계산해 환급액을 알려주는 프로그램.
환급율은 0.39 (39%).
[실행화면]
[소스코드]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MileageCalc { public partial class Form1 : Form { int startingMileage, endingMileage; double milesTraveled, amountOwed, reimburseRate = 0.39; private void btn_calcMiles_Click( object sender, EventArgs e) { MessageBox.Show(milesTraveled + " miles" , "Miles Traveled" ); } private void btn_Calc_Click( object sender, EventArgs e) { startingMileage = ( int )numericStart.Value; endingMileage = ( int )numericEnd.Value; if (endingMileage > startingMileage) { milesTraveled = endingMileage - startingMileage; amountOwed = milesTraveled * reimburseRate; lbl_result.Text = "$" + amountOwed.ToString(); } else { MessageBox.Show( "출발 시 주행거리는 도착 시 주행거리보다 작아야 합니다!" ); } } public Form1() { InitializeComponent(); } } } |
'C# > Head First C# Practice' 카테고리의 다른 글
슬라피 조의 샌드위치 하우스, 메뉴 랜덤하게 만들기(배열 연습) (1) | 2015.08.15 |
---|---|
인스턴스의 속성을 맞바꾸기 (0) | 2015.08.15 |
메서드를 만들 때 정적(static) 키워드를 사용하는 이유 (0) | 2015.08.09 |
ExchangeMoney, 돈 송수금 하기 (0) | 2015.08.09 |
Getting Start! 연습을 시작하며... (0) | 2015.08.09 |
Comments, Trackbacks