Computer Science, asked by AnimeBoy16, 1 month ago

Q1} Write the rules for naming a variable.
Q2} What do you understand by coercion? Give an illustrated example.
Q3} .Answer the following (10) 1 .Difference between Math.round() and math.ceil() in Java 1000 3000 15%
3000 5000 20%
5000 and above 25%
Q4} Question 6
Write A program to input three numbers and check whether they are equal or not.
If they are unequal numbers then display the greatest among them otherwise, display the message 'All the numbers are equals'.Sample Input: 34, 87, 61
Sample Output: Greatest Number: 87

Answers

Answered by revatipatildi
1

Explanation:

1. Answer :-

● Name your variables based on the terms of the subject area, so that the variable name clearly describes its purpose.

● Create variable names by deleting spaces that separate the words. ...

● Do not begin variable names with an underscore.

● Do not use variable names that consist of a single character.

2. Answer :-

Coercion means forcing a person to do something that they would not normally do by making threats against their safety or well-being, or that of their relatives or property. ... For example, pointing a gun at someone's head or holding a knife to someone's throat is an actual physical threat.

3. Answer :-

ceil() and Math. round() methods differ in a way that the former round off a number to its nearest integer in upward direction of rounding(towards the greater value) whereas the latter round off a number to its nearest integer in downward direction of rounding(towards lower value).

4. Answer :-

import java.util.Scanner;

public class Kboat3Numbers

{

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter first number: ");

int a = in.nextInt();

System.out.print("Enter second number: ");

int b = in.nextInt();

System.out.print("Enter third number: ");

int c = in.nextInt();

if (a == b && b == c) {

System.out.println("All the numbers are equal");

}

else {

int g = a;

if (b > g)

g = b;

if (c > g)

g = c;

System.out.println("Greatest number: " + g);

}

}

}

Similar questions