Computer Science, asked by rashmipradhan331, 3 months ago

write a program in java. to find the difference of two numbers85 and 27 and display their result in the output window​

Answers

Answered by Anonymous
31

Required Answer :

Question:

  • Write a program in java to find the difference of two numbers 85 and 27 and display their result in the output window.

Program:

This is the required Java program for the question.

public class diffrence

{

public static void main (String [] args)

{

int a=85;

int b=27;

int ans=a-b;

System.out.println("This is the required answer " +ans);

}

}

The output will be as follows:

This is the required answer 58.

Attachments:
Answered by BrainlyProgrammer
1

Answer:

There are two ways to do this...

Method 1:- By directly printing

package Programmer; //This is an optional statement, it is not necessary to write.

public class Difference {

public static void main (String ar []){

System.out.println("Difference: "+(85-27));

}

}

Method 2:- By storing in the variable.

package Programmer;

public class Difference {

public static void main (String ar []){

int a=85,b=27;

System.out.println("Difference: "+(a-b));

}

}

Method 3:-

package Programmer;

public class Difference {

public static void main (String ar[]){

int a=85,b=27,c;

c=a-b;

System.out.println("Difference: "+c);

}

}

Desired Output:-

  • Difference: 58
Similar questions