Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Understanding and use of variables of float and other data types.



P R A C T I C A L – A S S I G N M E N T S

Part 1 Java

Experiment No. 1:

Objective:

Understanding and use of variables of float and other data types.

Task:

Develop a simple Calculator application as per given screen snapshot, toImplement +, -, x and / operations. The text boxes get cleared when ‘C’ buttonis clicked.

 

Public Class:-

Float n1,n2,res;

char op;

1.CLEAR Button:-

t1.setText(null);

t2.setText(null);

t3.setText(null);

t3.setText(null);

 

2.EXIT Button:-

System.exit(0);

 

3.+ Button:-

n1=Float.parseFloat(t1.getText());

n2=Float.parseFloat(t2.getText());

res=n1+n2;

t3.setText(""+res);

4.- Button:-

n1=Float.parseFloat(t1.getText());

n2=Float.parseFloat(t2.getText());

res=n1-n2;

t3.setText(""+res);

5. *Button:-

n1=Float.parseFloat(t1.getText());

n2=Float.parseFloat(t2.getText());

res=n1*n2;

t3.setText(""+res);

6. / Button:-

n1=Float.parseFloat(t1.getText());

n2=Float.parseFloat(t2.getText());

res=n1/n2;

t3.setText(""+res);

 

 

Experiment No. 2:

Objective: Understanding the real life application requirement and developing a solution.

Task: Develop a Compound Interest Calculator application as per given screensnapshot, to calculate total amount for given Amount, Rate of Interest andTime using (A=P(1+R/100) T) and Interest I=A-P.

 

 

Public Class:-

float p,r,n,res,intamt;

1. CALCULATE BUTTON:-

p=Float.parseFloat(txtPA.getText());

r=Float.parseFloat(txtRate.getText());

n=Float.parseFloat(txtDur.getText());

res=(p*r*n)/100;

intamt=p-res;

txtSI.setText(""+res);

Tfintamt.setText(""+intamt);

2. Clear Button:-

txtPA.setText("");

txtRate.setText("");

txtDur.setText("");

txtSI.setText("");

3. EXIT Button

System.exit(0)

Experiment No. 3:

Objective: Understanding and use of Nested conditions in the Real life applications.

Task: A Quick Fox Transport Co. wants to develop an application for calculatingAmount based on distance and weight of goods.The charges (Amount) to be calculated as per rates given below.

 

Distance Weight Charges per Km.

>=500 Km >=100 kg. Rs. 5/-

>=10 and <100 kg. Rs. 6/-

< 10 kg. Rs. 7/-

<500 Km >=100 Kg. Rs.8/-

<100 Kg. Rs.5/-

 

 

Public Class:-

int w,d,a;

1. Calculate Button:-

t1.getText();

t2.getText();

w=Integer.parseInt(t3.getText());

d=Integer.parseInt(t4.getText());

if(d>=500 && w>=100)

{

a=d*5;

t5.setText(""+a);

}

else if(d>=500 && w<100 && w>=10)

{

a=d*6;

t5.setText(""+a);

}

else if(d<=500 && w<10)

{

a=d*7;

t5.setText(""+a);

}

else if(d<500 && w>=100)

{

a=d*8;

t5.setText(""+a);

}

else if(d<500 && w<100)

{

a=d*5;

t5.setText(""+a);

}

2. Exit Button:-

System.exit(0);

 


Дата добавления: 2015-11-05; просмотров: 26 | Нарушение авторских прав




<== предыдущая лекция | следующая лекция ==>
Створити інженерний калькулятор, який має два поля TEdit та TLabel, виконує арифметичні дії та обчислює: n!, sinx, cosx, tgx, ctgx, arctgx,arcctgx,arcsinx, arccosx, lnx, , , а також функція, | Клавиатуры CADDX control

mybiblioteka.su - 2015-2024 год. (0.006 сек.)