WAP a program to input two numbers and print their sum program should work aftet checking the password,which is abC(use scanner)
Answers
password = input ('Enter the password to commence the program : ' )
while password == 'abC' :
x = float (input('Enter your second number. ' ) )
y = float (input('Enter your second number. ' ) )
print ('Your sum is : ', x+y)
print ('\nDo you want to continue? If yes, type the correct password again : ' )
password = input ()
Answer:
import java.util.*;
class Numbers
{
public static void main (String args[ ])
{
Scanner in=new Scanner (System.in)
System.out.println("Enter the password");
String password=in.Next();
if(password != "abC")
{
System.out.println("Wrong password. Try again");
password=in.nextInt();
}
System.out.println("Enter the two numbers");
int n= in.nextInt();
int m=in.nextInt();
System.out.println("Sum of the two numbers="+(m+n));
}
}