unit 12: software delvelopement€¦  · web viewinput requirements . the user will enter the...

28
9800227295 UNIT 12: SOFTWARE DELVELOPEMENT

Upload: others

Post on 24-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

unit 12: software delvelopement

9800227295

Page 2: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

1

ContentsIntroduction...........................................................................................................................................2

Purpose of the system...........................................................................................................................3

Problem definition.................................................................................................................................4

Requirements........................................................................................................................................5

Business Requirements......................................................................................................................5

Input Requirements.......................................................................................................................5

Interface Design.....................................................................................................................................6

Design One:...........................................................................................................................................6

Screen navigation Design 1:...............................................................................................................6

Supporting table for Design 1:...........................................................................................................7

Design Two:...........................................................................................................................................7

Supporting table for Design 2:...........................................................................................................8

Data Dictionary......................................................................................................................................9

Software Structures.............................................................................................................................10

Flowchart.............................................................................................................................................11

Test Plan..............................................................................................................................................12

Implementation...................................................................................................................................12

Copy of the Code.............................................................................................................................12

Test Plan..............................................................................................................................................17

Review.................................................................................................................................................24

Business Requirements....................................................................................................................24

Input Requirements.....................................................................................................................25

Page 3: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

2

Introduction

Page 4: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

3

Purpose of the system

The program will calculate the currency from Sterling pound to Euro, Polish Zloty and few other currencies. It will also calculate the foreign currency (e.g. Polish Zloty & Euro) to Sterling pound. The program will also check online what the current rate is, so it will be up to date with all currency exchange rates.

The user will have to put the amount of money they want to convert to a foreign currency (e.g. £30 to Polish Zloty = 153.48 zl). He will have to put the amount of money in a box called “Amount”. He will then have to choose the currency he want to exchange the money to. Then he will click on the button “Convert” and the converted amount of money will be displayed.

The system must be accurate! It’s not allowed to make mistakes when calculating the correct amount of money and it should give the answer straight away.

Page 5: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

4

Problem definition

Current system works well, but it could work much more effectively and faster. Also, current system have some serious problems such as incorrect calculation as it’s not up to date with international currency rates that can change every day. Also, sometimes the user (travel agent) has to use a “pen and paper” method where he would have to calculate the exchange amount on the calculator. That would take the company much more time and if the travel agent would make a mistake it would cost the company a lot of money.

Page 6: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

5

Requirements

The business’ requirements are to create a new system that will help to calculate different currencies correctly and without errors. The new system should:

- Be easy to use- Allow the user to choose a different currencies- Allow to put the amount they would like to exchange- Allow to put the amount of money they’d like to exchange- Be fast- Be always correct- Be always up to date with currency rates

Business RequirementsCurrently business is using a ‘pen and paper’ method to calculate the currency exchange. It means that they have to check the current rate online, then calculate it using a calculator or on paper using their mathematics skills and knowledge. This method takes a lot of time as sometimes it can take few minutes. Also, some of the calculations are incorrect, which means that the company or the client is losing money.

Input Requirements The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example Euro (€). After this the program will allow the user to enter the amount of money the user would like to convert, e.g. £10. The program will also allow the user to enter and exchange foreign currency (e.g. Euros) and exchange it to British Pounds.

Output RequirementsThe program will display the up-to-date currency exchange for chosen currencies (e.g. from British Pounds to Euros) which is: £1 = €1.17. After the user press the button called ‘convert’ the program will display the exchanged amount. The exchanged rate from British Pounds to Euros should be €11.73.

Processing RequirementsThe program will find the current exchange rate. Calculate the amount and then display the answer (exchanged amount) on the screen.

Page 7: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

6

Interface Design

Input Object Name ActionCurrency from List box LstCurrencyFm SelectedItemCurrency to List box LstCurrencyTo SelectedItemExchange rate Radio button RdBttm NoneAmount Textbox Txtbox ChkItemSubmit Input Button btnCalculate Click

Output Object Name ActionCorrect exchanged amount

Label Lbl N/A

Error Message MessageBox MsgBox N/A

Design One:Screen navigation Design 1:When you first open the Exchange Calculator you will have few options. First you will choose your “Currency From”, the currency you want to exchange (e.g. British Pounds). You will then choose the “Currency To”, the currency you want to exchange it to (e.g. Euro). The calculator will tell you what the exchange rate between the two is. Now you will put the amount you want to exchange (for example £15) and click the “Exchange” button. The “Exchanged Amount” will then be displayed in the text box.

Exchange Calculator

Enter Currency From Enter Currency To

Pound (£) Euro (€)Exchange

15 17.46

Exchanged AmountAmount

€1.16

Exchanged Rate

12

4 6

5

3

Page 8: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

7

Supporting table for Design 1:

No. Component Type

Text Type

Font Type

Font Colour

Font Size

Background Colour

Event (Action)

1. Currency from

String Celibri R:0 G:0 B:0

14 R:189 G:215 B:238

N/A

2. Currency to String Celibri R:0 G:0 B:0

14 R:189 G:215 B:238

N/A

3. Exchange rate

String Celibri R:0 G:0 B:0

14 R:189 G:215 B:238

N/A

4. Amount String Celirbi R:0 G:0 B:0

14 R:189 G:215 B:238

N/A

5. Submit Input

None Celibri R:52 G:2

B:236

16 R:247 G:250 B:253

N/A

6. Exchanged Amount

String Celibri R:0 G:0 B:0

14 R:189 G:215 B:238

N/A

Design Two:

Exchange Calculator

Enter Currency From Enter Currency To

Pound (£) Euro (€)Exchange

15 17.46

Exchanged AmountAmount

€1.16

Exchanged Rate

Page 9: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

8

Supporting table for Design 2:

No. Component Type

Text Type

Font Type

Font Colour

Font Size

Background Colour

Event (Action)

1. Currency from

String Celibri R:0 G:0 B:0

14 R:255G:192

B:0

N/A

2. Currency to String Celibri R:0 G:0 B:0

14 R:168 G:183 B:223

N/A

3. Exchange rate

String Celibri R:0 G:0 B:0

14 R:68G:114 B:196

N/A

4. Amount String Celirbi R:0 G:0 B:0

14 R:168 G:183 B:223

N/A

5. Submit Input

None Celibri R:52 G:2

B:236

16 R:247 G:250 B:253

N/A

6. Exchanged Amount

String Celibri R:0 G:0 B:0

14 R:168 G:183 B:223

N/A

Page 10: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

9

Data Dictionary

Name Data Type Default Values

Range Value Use Size (bytes)

Exchange Rate

Double 0.0D (+/-)5.0 x 10-

324 to (+/-)1.7 x 10308

This is the difference

between your currency from

and your currency to.

8 bytes

Currency From

String Null 0 - 2 billion The currency you want to exchange.

10 bytes + string length

Currency To String Null 0 - 2 billion The currency you want to

get.

10 bytes + string length

Amount Double 0.0D (+/-)5.0 x 10-

324 to (+/-)1.7 x 10308

The amount of money you

want to exchange.

8 bytes

Exchanged Amount

Double 0.0D (+/-)5.0 x 10-

324 to (+/-)1.7 x 10308

The amount you are going

to receive after exchanging the

currency.

8 bytes

Page 11: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

10

Software Structures

The program is broken up into classes. Each class will have a job to do. A method is a small piece of code that will carry out an action. The method will help the class complete its job.

1. Get user input and store it.2. Get selected currency to and from and store it.3. Get and store updated Exchange Rate.4. Check for errors.5. Find exchange rate from array.6. Calculate.7. Display.

Page 12: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

11

Flowchart

Page 13: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

12

Test Plan

Test No.

Test. Test Data.

Expected. Actual. Screenshot.

1. Loading the screen.

N/A. The screen to be loaded.

2. Check the combo boxes (Currency From).

N/A The combo box will show me a list of different currencies.

3. Check the combo boxes (Currency To).

N/A The combo box will show me a list of different currencies.

4. Check the calculation button.

N/A The calculation button should work and calculate the exchange rate.

5. Check the calculation button.

Pounds to DollarAmount 10

The calculation button should work and calculate the exchange rate.

Implementation

Page 14: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

13

Copy of the Code

namespace Exchange_Rate_Calculator{ public partial class Form1 : Form { //The line below will show me //The correct currency exchange rate double exchangeRate = 0; //This will store the currency from string CurrencyFrom = ""; //This will store currency to string CurrencyTo = ""; string to = ""; string from = ""; //The line below will store the amount of money //The variable below will store numbers double Amount = 0; //The line below will show me exchanged rate //The variable below will slso store numbers double exchangedAmount = 0; //The array below (a table) will store echange rate //These are exchange rates for different countries String[,] exchangeRateTable= new string[,] { {"British Pound", "US Dollar", "1.22"}, {"US Dollar", "British Pound", "0.78"}, {"British Pound", "Polish Zloty", "5.32"}, {"Polish Zloty", "British Pound", "0.32"}, {"British Pound", "Euro", "1.19"}, {"Euro", "British Pound", "0.84"}, {"British Pound", "Canadadian Dollar", "1.68"}, {"Canadian Dollar", "British Pound", "0.60"}, {"British Pound", "Japanese Yen", "143.86"}, {"Japanese Yen", "British Pound", "0.0070"}};

public Form1() {

//the line below will construct the class and build the GUI InitializeComponent(); // Populate Combo Boxes //MessageBox.Show("The Length of the array is " + exchangeRateCalc.Length); }

Page 15: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

14

private void label1_Click(object sender, EventArgs e) {

}

private void Form1_Load(object sender, EventArgs e) {

}

public void exchangeRateCalc() { exchangeRate = 0;

for (int count = 0; count < exchangeRateTable.GetUpperBound(0) + 1; count++) //this repeat the code untin it reaches the amount of rows in the array. //the count++ adds 1 to the row number each loop. { string from = exchangeRateTable[count, 1]; //This line here will get the country (currency) from //by useing the coordinates of row,0 (these state the collumn and row), thet is stored in the array

string to = exchangeRateTable[count, 2]; // this line here will get you the country (currency) to //that is stored in the array

if (CurrencyFrom == from && CurrencyTo == to) //this comoares the data that is stored with //the user input. if the value stored in currencyFrom is qual the value stored in //the variable from (AND) if the value stored in currencyTo is equal to the value stored in the variable to. Then it will run the following lines. { exchangeRate = Convert.ToDouble(exchangeRateTable[count, 0]);

} } MessageBox.Show("Sorry, Could't Find The Exchange Rate Requested"); //this line is an error //that tells the user that their requested echange rate is unavailable. }

private void textBox2_TextChanged(object sender, EventArgs e) {

}

private void lstEnterCurrencyFrom_SelectedIndexChanged(object sender, EventArgs e) {

}

private void SelectCurrencyFrom_TextChanged(object sender, EventArgs e) {

Page 16: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

15

}

private void SelectCurrencyFrom_Click(object sender, EventArgs e) {

}

private void textBox1_TextChanged(object sender, EventArgs e) {

}

private void lblAmount_Click(object sender, EventArgs e) {

}

public void Amount1() { CurrencyFrom = this.cmbFrom.SelectedItem.ToString(); CurrencyTo = this.cmbTo.SelectedItem.ToString(); Amount = Convert.ToDouble(this.txtAmount.Text); }

public void updateRate() //this is a method to update the exchange rate in the array { exchangeRate = Convert.ToDouble(txtExchangeRate.Text); //it gets the exchange rate from a textbox //and stores it into a variable if (exchangeRate > 0) //if exchange rate is greater then 0 then for (int count = 0; count < exchangeRateTable.GetUpperBound(0) + 1; count++) { //loop through the array table to find a match string from = exchangeRateTable[count, 0]; //this gets the Currency From string to = exchangeRateTable[count, 1]; //this gets the Currency To if (CurrencyFrom == from && CurrencyTo == to) { //checks to see if the user input for country (currency) from and country (currency) to //matches the those stored in the array on the same row. If true then

exchangeRateTable[count, 2] = txtExchangeRate.Text; //update Exchange Rate } }

}

public void Calculation() {//this calculates the amount to exchange if (exchangeRate == 0) //if the value in customExchange is - then { MessageBox.Show("Please enter valid input"); //show messagebox with erroe message else } else { exchangedAmount = Amount * exchangeRate; //workout exchange amount

Page 17: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

16

}

} public void Display() //This method displays the results { txtExchangedAmount.Text = Convert.ToString(exchangedAmount); //the result is then displayed in a albel }

private void cmbFrom_SelectedIndexChanged(object sender, EventArgs e) {

} }}

Page 18: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

17

Test Plan

Test No.

Test. Test Data.

Expected.

Actual. Screenshot.

1. Loading the screen.

N/A. The screen to be loaded.

The screen is loaded and there are no errors.

2. Check the combo boxes (Currency From).

N/A The combo box will show me a list of different currencies.

The list is empty.

3. Check the combo boxes (Currency From).

N/A The combo box will show me a list of different currencies.

The combo box is fixed and now it works correctly.

Page 19: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

18

4. Check the combo boxes (Currency To).

N/A The combo box will show me a list of different currencies.

The list is empty.

5. Check the combo boxes (Currency To).

N/A The combo box will show me a list of different currencies.

The combo box is fixed and now it works correctly.

6. Check the calculation button.

N/A The calculation button should work and calculate the exchange rate.

The calculation button does not work.

Page 20: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

19

7. Check the calculation button.

N/A The calculation button should work and calculate the exchange rate.

The button is not crashing anymore but it shows an invalid information.

8. Check the calculation button.

Pounds to DollarAmount 10

The calculation button should work and calculate the exchange rate.

Now the button shows the correct exchanged amount but does not show the exchange rate.

9. Check the calculation button.

Pounds to DollarAmount 10

The calculation button should work and calculate the exchange rate.

Now everything works correctly.

Page 21: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

20

Test 5 – Fixed code

private void btnCalculate_Click(object sender, EventArgs e) { //fixed code //the reason that nothing is happening after I click a calculation button is that there is no code. Amount1(); updateRate(); exchangeRateCalc(); Calculation(); Display(); }

Test 6 – fixed code

public void updateRate() //this is a method to update the exchange rate in the array { //fix code //the try catch will stop the programme from crashing when the user will enter the invalid input. try { exchangeRate = Convert.ToDouble(txtExchangeRate.Text); //it gets the exchange rate from a textbox } catch (Exception e) { txtExchangeRate.Text = "0"; exchangeRate = 0; } //and stores it into a variable if (exchangeRate > 0) //if exchange rate is greater then 0 then for (int count = 0; count < exchangeRateTable.GetUpperBound(0) + 1; count++) { //loop through the array table to find a match string from = exchangeRateTable[count, 0]; //this gets the Currency From string to = exchangeRateTable[count, 1]; //this gets the Currency To if (CurrencyFrom == from && CurrencyTo == to) { //checks to see if the user input for country (currency) from and country (currency) to //matches the those stored in the array on the same row. If true then

exchangeRateTable[count, 2] = txtExchangeRate.Text; //update Exchange Rate } }

}

Page 22: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

21

public void exchangeRateCalc() { exchangeRate = 0;

for (int count = 0; count < exchangeRateTable.GetUpperBound(0) + 1; count++) //this repeat the code untin it reaches the amount of rows in the array. //the count++ adds 1 to the row number each loop. {

//fix code //the column numbers were mixed up string from = exchangeRateTable[count, 0]; //This line here will get the country (currency) from //by useing the coordinates of row,0 (these state the collumn and row), thet is stored in the array

string to = exchangeRateTable[count, 1]; // this line here will get you the country (currency) to //that is stored in the array

if (CurrencyFrom == from && CurrencyTo == to) //this comoares the data that is stored with //the user input. if the value stored in currencyFrom is qual the value stored in //the variable from (AND) if the value stored in currencyTo is equal to the value stored in the variable to. Then it will run the following lines. { exchangeRate = Convert.ToDouble(exchangeRateTable[count, 2]);

} }

//fix code //the if statement will show the error message only if the exchange rate will be 0. if (exchangeRate == 0) { MessageBox.Show("Sorry, Could't Find The Exchange Rate Requested"); //this line is an error //that tells the user that their requested echange rate is unavailable. } }

Test 8 – fixed code

public void exchangeRateCalc() { exchangeRate = 0;

for (int count = 0; count < exchangeRateTable.GetUpperBound(0) + 1; count++) //this repeat the code untin it reaches the amount of rows in the array. //the count++ adds 1 to the row number each loop. {

//fix code

Page 23: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

22

//the column numbers were mixed up string from = exchangeRateTable[count, 0]; //This line here will get the country (currency) from //by useing the coordinates of row,0 (these state the collumn and row), thet is stored in the array

Test 9 – fixed code

public void Display() //This method displays the results { //fixed code //I amended the "Amount" and the "Exchange Rate" so the programme could display the exchange rate. txtExchangedAmount.Text = "Amount "+ Convert.ToString(exchangedAmount) + " Exchange Rate " + exchangeRate; //the result is then displayed in a albel }

private void cmbFrom_SelectedIndexChanged(object sender, EventArgs e) {

}

Page 24: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

23

Review

The business’ requirements are to create a new system that will help to calculate different currencies correctly and without errors. The new system is now:

- Easy to use- Allowing the user to choose a different currencies- Allowing to put the amount they would like to exchange- Allowing to put the amount of money the user would like to exchange- Is fast and sufficient- Is always correct- Is always up to date with currency rates

Business RequirementsThe new program allows the user to enter the information in on GUI and does not require a pen and paper. The program is also checking for the up to date currency exchange rates online and is updating the changes automatically itself. As the program has the latest currency exchange rates for a number of different currencies it will then exchange the amount straight away after pressing Exchange button. It will not make any incorrect calculations and will give the correct exchanged amount immediately which means the company will save more time and will not lose money, or customers.

Page 25: unit 12: software delvelopement€¦  · Web viewInput Requirements . The user will enter the currency from, for example British Pound (£). Then choose the currency to, for example

24

Input Requirements The user is now able to choose two different currencies from two of the combo boxes (for example British Pounds to Polish Zloty (zl / PLN)) and input the amount of money into a text box, for example £10. Now the user will press the Convert button and will receive the currency rate displayed on screen. At the same time the program will display correct exchanged amount of money, in this case it would be 4.95 Polish Zloty (zl / PLN). The user is now able to convert foreign currency to British Pounds. The user will do exactly the same thing as before but now in the combo box ‘Currency From’ will choose a foreign currency and in ‘Currency To’ will choose British Pounds. The user can now exchange foreign currencies between other foreign currencies as well.

Output RequirementsThe program is now able to check for the latest changes in world currencies online and displays the up-to-date currency exchange rate between two chosen currencies without any problems and errors. When the user press on the button “convert” the program will now display the exchanged amount of money and will not display any error messages.

Processing RequirementsThe program is now able to check for the latest changes in world currencies online and displays the up-to-date currency exchange rate between two chosen currencies without any problems and errors. It will also make the calculation and will display the exchanged amount on screen.