Computer Science, asked by neelusharma3579, 2 months ago

Write a program using Scanner class.
Enter three numbers and a character . Find and display the sum of the numbers if the given character is 'p'. The program displays a message "Invalid Character" if the user enters a letter other than 's' or'p' .​

Answers

Answered by drishti3275
1

Answer:

Mark me brainliest please. thanks

Explanation:

import java.util.Scanner;

class program

{

static void display ()

{

int sum=0;

Scanner sc=new Scanner(System.in);

System.out.println("Enter 3 numbers");

a=sc.nextInt();

b=sc.nextInt();

c=sc.nextInt();

System.out.println("Enter a character");

character d=sc.next().charAt(0);

if character == 'p' or character == 'p';

{

sum=a+b+c;

System.out.println("Sum=" + sum);

}

else

System.out.println("Invalid Characte4");

}

}

}

Similar questions