Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
C- pro

C- pro

Ratings: (0)|Views: 10|Likes:
Published by api-3845857

More info:

Published by: api-3845857 on Oct 18, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Question 1
Rewrite the programme given in \u2018Assignment 1- Question 3\u2019 using functions. There

should be 4 functions defined in your programme.
Function 1: A function which displays the Menu.
Function 2: A function which calculates the current in an electrical circuit.
Function 3: A function which calculates the acceleration of a car
Function 4: A function which calculates the intercept of a straight line graph

Question 2
Declare an array, which can hold 5 integer elements. The user should be given the
opportunity to enter 5 values into the array from the keyboard.
a) Using a pointer, store the values that the user has entered in the array.
b) Calculate and display the average of the array elements.
c) Arrange the values in the array according to descending order (from the highest
value to the lowest value) and display the answer.
Hint: You should use nested loops and a temporary variable in order to arrange the
values in descending order.
Question 3
You need to write a password registration programme. Your programme should be
structured in the flowing way.
Take user input
(
first name, last name, user name,
p
assword
Password less than
7 characters
Ask the user to re-
enter password
Take user input
(password)
Password more than
7 characters
Password less
than 7 characters
Password more
than 7 characters
Display login
details
Programme
quit

Password
re-entered
correctly

Password
re-entered
incorrectly

\ue000At the start of your programme, the user should be given the opportunity to
enter his/her first name, last name, a user name and a passwordseparately.
\ue000The password should have a minimum of 7 characters. If the password is less

than 7 characters, your programme should display an error message and give the opportunity for the user to enter a password again and again until the user enters a password of more than 7 characters.

\ue000If the password is more than 7 characters your programme should ask the user

to re-enter password in order to confirm the password that he/she has entered. If the user has re-entered a different password the programme should display and error message and should quit the programme.

\ue000If the re-entered password matches with the previously entered password, your
programme should display the following output on the screen.
Hint: Use string functions.
Question 4
Write a programme, which is a bank account, which records the balance of money for
a given customer. Your programme should perform the three transactions given below.

a) Checking the bank balance- Bank balance may have a positive orcred it balance where the bank holds money on behalf of the customer; or a negative ordebi t balance where the customer owes the bank money. If the bank balance is a negative value you should display a message indicating that the customer has a debit value. If the bank balance is zero you should display a message indicating that the account has no money.

b) Deposit money \u2013 The money that the customer deposits should be added to the
balance.
c) Withdraw money- The money that the customer withdraws should be deducted
from the balance.

Define a class called \u2018Account\u2019. You should define three different public member functions in order to carry out the above three transactions and a private member data called \u2018balance\u2019 in order to perform the calculations. Define a constructor which initializes the default bank balance to zero (0). You should define a destructor for the class as well.

Create three objects as given below and perform the following transactions and
display the balance to the user.
*******Your Login Details ******
Name:
Nimal Perera
User Name: NPerera
Password:
book001

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->