C++ program that generates output as 5 10 9.

Q33. Write a program that generates the following output:

        5

        10

        9

Assign value 5 to a variable using =. Multiply it with 2 to generate 10 and subtract 1 to generate 9.

Ans.

#include<iostream.h>

#include<conio.h>  //for clrscr()

void main()

{

int value;

value=5;

clrscr();   //for clear screen

cout<<“\n “<<value; Read More …

C++ program that read values of w, x, y and z and display the value of P.

Q28. Write a program to read values of w, x, y and z and display the value of P, where

P= w+x / y-z

Ans.

#include<iostream.h>

#include<conio.h>   //for clrscr()

void main()

{

int w,x,y,z,P;

clrscr();          //for clear screen

cout<<“\n Enter the value of w: “;

cin>>w;

cout<<“\n Enter the value of x: “; Read More …

Application for Username and Password.

Q19. Design a Java NetBeans GUI application for checking Username and  Password.

Sol:

Create a GUI application as per following screenshot.

Code For Log In

Type the following code by double clicking jButton1, button, below the line that says, ‘// TODO add your handling code here’

 

String user;

user=jTextField1.getText();

String pwd;

pwd=new String(jPasswordField1.getPassword());

if(user.equals(“CHB”) && pwd.equals(“root”))

JOptionPane.showMessageDialog(null,”Log In Successfull”);

else

JOptionPane.showMessageDialog(null,”Invalid Username or Password”);

}

Output:

 

Count Lowest to Highest.

Q18. Design a Java Netbeans 6.5.1 GUI application having interface as shown below :

 The loop for the frame should print numbers from lowest to highest on the basis of given two numbers, upon clicking at “Count” button.

Sol:

Type the following code by double clicking jButton2, button, below the line that says, ‘// TODO add your handling code here’

 

 

int num1,num2;

num1=Integer.parseInt(jTextField1.getText()); Read More …

Simple Interest Programme.

Q16. Design Java Netbeans 6.5.1 an application that accepts principal amount, rate of interest and time from the user. Then it computes the simple interest and displays it.

Sol:

Create a GUI application as per following screenshot.

Type the following code by double clicking Button1, button, below the line that says, ‘// TODO add your handling code here’

jTextField1.setText(“”);

jTextField2.setText(“”);

jTextField3.setText(“”);

jTextField4.setText(“”);

jTextField5.setText(“”);

}

Type the following code by double clicking Button2, button, below the line that says, ‘// TODO add your handling code here’

double prin,rate,time,sim,total;

prin=Double.parseDouble(jTextField1.getText());

rate=Double.parseDouble(jTextField2.getText());

time=Double.parseDouble(jTextField3.getText());

sim=(prin*rate*time)/100;

jTextField4.setText(sim+””);

total=prin+sim;

jTextField5.setText(total+””);

}

Type the following code by double clicking Button3, button, below the line that says, ‘// TODO add your handling code here’

System.exit(0);

}

Output:

Students Result in JAVA NETBEANS IDE 6.5.1

Q15. Design an application in JAVA NETBEANS IDE 6.5.1 to prepare students result on the basis of marks entered.

Sol:

Create a GUI application as per following screenshot.

 

Type the following code by double clicking  jButton1 , button, below the line that says, ‘// TODO add your handling code here’

jTextField1.setText(“”);

jTextField2.setText(“”);

jTextField3.setText(“”);

jTextField4.setText(“”);

jTextField5.setText(“”);

jTextField6.setText(“”);

jTextField7.setText(“”); Read More …

Boiling Point Of Water(if…else)

Q14. Program to obtain boiling point of water from user and report whether the user has entered the correct answer or not. Make use of if…else statement.

(Hint. Boiling point of water is 100C.)

Sol:

Create a GUI application as per following screenshot.

 

Type the following code by double clicking BtnAdd, button, below the line that says, ‘// TODO add your handling code here’

String t1=txt1.getText();

double temp=Double.parseDouble(t1);

if(temp==100)

lbl1.setText(“You are right. It is 100C”);

else

lbl1.setText(“No. It is 100C”);

}

 

OUTPUT:

Java Netbeans 6.5.1 Program That Print Largest Of The Three.

Q13. Design a Java Netbeans 6.5.1 program that accept three integer and print the largest of the three. Make  the use of only if statement.

Sol:

Create a GUI application as per following screenshot.

Type the following code by double clicking BtnLar, button, below the line that says, ‘// TODO add your handling code here’

int x,y,z;

x=Integer.parseInt(txt1.getText());

y=Integer.parseInt(txt2.getText());

z=Integer.parseInt(txt3.getText()); Read More …