Реферат

Реферат на тему Draughts Essay Research Paper Program construction The

Работа добавлена на сайт bukvasha.net: 2015-06-18

Поможем написать учебную работу

Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.

Предоплата всего

от 25%

Подписываем

договор

Выберите тип работы:

Скидка 25% при заказе до 11.11.2024


Draughts Essay, Research Paper

Program construction

The completed programs to be submitted to the charon system by the date indicated.

C++ Familiarisation

You should expect to finish this work by the end of week 3 (Now week 4 due to non availability

of the Borland C++ compiler in the labs) at the latest. The completed programs to be submitted to

the charon system by this date.

A non extendable extension for this work is granted till the end of week 4 (Now week 5).

However, for your own personal satisfaction the charon system will still judge your work after this

date.

Exercise 1.1

Hello world

A program to write out the greeting message “hello world” to the terminal.

Input

Expected output

Hello world

Key points

A first C++ program

Using C++ Builder

Exercise 1.2

Times Table

A program to print out the 5 times table.

Input

Expected output

1 * 5 = 5

2 * 5 = 10

3 * 5 = 15

4 * 5 = 20

5 * 5 = 25

6 * 5 = 30

7 * 5 = 35

8 * 5 = 40

9 * 5 = 45

10 * 5 = 50

11 * 5 = 55

12 * 5 = 60

Key points

Using loops

Output of numbers and text

Exercise 1.3

Times Table the general case

A program to print out any times table. The input to this program is an integer number specifying which time table is to be

printed.

Hint:

int num; std::cin >> num;

would read a decimal number into the variable num.

Input

Expected output

2

1 * 2 = 2

2 * 2 = 4

3 * 2 = 6

4 * 2 = 8

5 * 2 = 10

6 * 2 = 12

7 * 2 = 14

8 * 2 = 16

9 * 2 = 18

10 * 2 = 20

11 * 2 = 22

12 * 2 = 24

Key points

Using loops

Output of numbers and text

Input of numbers in C++

Exercise 1.4

Order

A program to read in three integer numbers and print them out in ascending order. For example, if the numbers input were 10

7 8 then your output would be:

7 8 10

Input

Expected output

10 7 8

7 8 10

Key points

Selection constructs

Input/output of numbers in C++

To gain familiarity with nested selection statements.

Exercise 1.5

Calculator

A program to implement a desk calculator that has no operator precedence. For example, if the formula 2 + 3 * 4; where

input the result would be 20. Likewise if the formula 4 + 3 * 2; where input the result would be 14.

Input

Expected output

2 + 3 * 4;

Answer = 20

3 + 4 * 2 + 1;

Answer = 15

To gain familiarity with loops and selection statements.

Hint: A syntax diagram for the expression is shown below:

+———+ +——+

—————-| Number |————-| ; |—

/ +———+ \ +——+

| |

| +———+ |

\——| + – * / |——/

+———+

This shows that a valid expression is a number followed by either a ‘;’ or the operator ‘+’, ‘-’, ‘*’, ‘/’. If an operator is found

then the next item expected is a number. If the next item found is a ‘;’ then the expression is finished.

Key points

Revision of loops and selection constructs in C++

Input of characters and numbers

Syntax diagrams

Building a class

Exercise 2.1

You should expect to finish this work by the end of week 6 (Now week 7) at the latest. The

completed programs to be submitted to the charon system by this date.

A non extendable extension for this work is granted till the end of week 7 (Now week 8).

However, for your own personal satisfaction the charon system will still judge your work after this

date.

The exercise is to create the class Employee_pay that can be used as part of a larger program to manage the pay of

employees in a SME (Small to Medium Enterprise). The responsibilities of the class Employee_Pay are as follows:

Method

Responsibility

set_hourly_rate

Sets the hourly rate.

add_hours_worked

Accumulates the number of hours worked so far.

pay

Delivers the pay for this week. Tax is deducted at 20% of the

total pay.

reset

Resets the hours worked back to zero.

hours_worked

Delivers the number of hours worked so far this week.

pay_rate

Delivers the hourly pay rate.

The partial C++ specification of this class is shown below:

class Employee_Pay

{

public:

Employee_Pay();

void add_hours_worked( int number_of_hours_worked );

void set_hourly_rate( float hourly_pay_rate );

void reset();

float pay();

int hours_worked();

float pay_rate();

private:

};

You may wish to use the following test program to help test the class that you have created.

#include

#include

void main()

{

std::cout

318


1. Реферат на тему Charlotte S Web And Watership Down Essay
2. Реферат Российская культура
3. Реферат на тему Early Christian Exam Art His And Appre
4. Книга Как писать так, чтобы было понятно всем!, Аллан Пиз
5. Лабораторная_работа на тему Діагностичні програми
6. Реферат Становление и развитие охраны здоровья на белорусских землях
7. Диплом Бухгалтерський облік в Україні
8. Курсовая Внутриличностный конфликт студентов-психологов обучающихся в ВУЗе
9. Доклад на тему Цивилизация Майя
10. Реферат Русско-турецкая война 1686 1700