0% found this document useful (0 votes)
6 views5 pages

Java Exam

The document contains multiple Java programs that demonstrate basic programming concepts such as temperature conversion from Fahrenheit to Celsius, age categorization using if-else statements, increment and decrement operations, logical conditions with user input, and a switch statement for digit recognition. Each program prompts the user for input and provides output based on the logic implemented. These examples serve as educational tools for understanding fundamental programming structures and user interaction in Java.

Uploaded by

kowsikur2012
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Java Exam

The document contains multiple Java programs that demonstrate basic programming concepts such as temperature conversion from Fahrenheit to Celsius, age categorization using if-else statements, increment and decrement operations, logical conditions with user input, and a switch statement for digit recognition. Each program prompts the user for input and provides output based on the logic implemented. These examples serve as educational tools for understanding fundamental programming structures and user interaction in Java.

Uploaded by

kowsikur2012
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Fahernheit

package [Link];

import [Link];

public class fahernheit {


public static void main(String[] args) {

Scanner input = new Scanner([Link]);

double Fahrenheit,hote;

[Link]("type a Fahrenheit : ");


Fahrenheit = [Link]();

hote = 0.55 * (Fahrenheit-32);


[Link](" Celsius: "+hote);

IfElse
package [Link];

import [Link];

public class IfElse {

public static void main(String[] args) {

Scanner input = new Scanner([Link]);


double age;

[Link]("Enter your age: ");


age = [Link]();

if(age>=80){
[Link]("One foot in the grave");
}

else if(age>=70){
[Link]("The beginning of illness");
}

else if(age>=60){
[Link]("I'm not going to get sick yet.");
}

else if(age>=50){
[Link]("End of career");
}

else if(age>=40){
[Link]("Not old yet, on the way to old age");
}

else if(age>=30){
[Link]("Now you are a young man");
}

else if(age>=20){
[Link]("No fenish your ten ager");
}

else if(age>=10){
[Link]("Stirt a school life");
}

else{
[Link]("Now you are a child");
}

IncrerementDerement
package [Link];

import [Link];

public class IncrerementDerement {


public static void main(String[] args) {

Scanner input = new Scanner([Link]);


int x,result;

[Link](" X is :" );
x = [Link]();

result = ++x;
[Link](" result is :" + result);

result = x++;
[Link](" result is :" + result);

result = --x;
[Link](" result is :" + result);

result = x--;
[Link](" result is :" + result);

LogiclOr
package [Link];

import [Link];

public class LogiclOr {

public static void main(String[] args) {

Scanner input = new Scanner([Link]);

[Link]("do you java lover?:");


String answer= [Link]();

if([Link]("M") || [Link]("m")){
[Link]("you are a java lover");
}

else if([Link]("k") || [Link]("K")){


[Link]("you are not a java lover");
}

else{
[Link]("Invelide input");
}
}

Swhtch
package [Link];

import [Link];

public class Swhtch {

public static void main(String[] args) {

Scanner input = new Scanner([Link]);

int digit;
[Link]("Enter a digit : ");
digit = [Link]();
switch(digit){

case 0:
[Link]("Zero");
break;

case 1:
[Link]("One");
break;

case 2:
[Link]("Two");
break;

case 3:
[Link]("Three");
break;

case 4:
[Link]("Four");
break;

case 5:
[Link]("Five");
break;
case 6:
[Link]("Six");
break;

case 7:
[Link]("Seven");
break;

case 8:
[Link]("Eight");
break;

case 9:
[Link]("Rodela");
break;

default:
[Link]("Invalid input");
}
}

You might also like