Computer Science, asked by shantannu2003, 11 months ago

WAP a program to input two numbers and print their sum program should work aftet checking the password,which is abC(use scanner)​


shambhavi2807: What kind of password?
shantannu2003: you have to use the password which is abC.If you enter wrong password the output should be"wrong password"and if you type the given password the output os the sum of two numbers

Answers

Answered by guptauday49
0

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 ()

Answered by shambhavi2807
2

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));

}

}


shambhavi2807: If understood please mark it as brainliest. Thank you.
shantannu2003: sorry I cannot because it is not completely correct
shambhavi2807: how?
shambhavi2807: I've made a change there. There was a mistake
Similar questions