0% found this document useful (0 votes)
7 views8 pages

Java Programs for Basic Calculations

The document contains four Java programs: one for converting Celsius to Fahrenheit, another for finding the largest of two integers using a conditional operator, a third for displaying command line arguments, and a fourth for calculating the sum and average of marks. Each program includes its aim, code, output, and a confirmation of successful execution. Overall, the document serves as a tutorial for basic Java programming concepts and functionalities.

Uploaded by

tharandharani53
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)
7 views8 pages

Java Programs for Basic Calculations

The document contains four Java programs: one for converting Celsius to Fahrenheit, another for finding the largest of two integers using a conditional operator, a third for displaying command line arguments, and a fourth for calculating the sum and average of marks. Each program includes its aim, code, output, and a confirmation of successful execution. Overall, the document serves as a tutorial for basic Java programming concepts and functionalities.

Uploaded by

tharandharani53
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

1.

Write a Java program to read the temperature in


Celsius and convert into Fahrenheit.

AIM:
Write a Java program to read the temperature in Celsius and
convert into Fahrenheit.
PROGRAM:
class Convert{
public static void main(String args[])
{
int C;
float F;
C=[Link](args[0]);
F=C*(9/5)+32;
[Link]("Fahrenheit Value is=" +F);
}
}
OUTPUT:
>>java Convert 90
>>Fahrenheit Value is=122.0

RESULT:
Thus the java program to read the temperature in Celsius and
convert into Fahrenheit is executed Successfully.
2).Write a program to read 2 integers and find the largest
number using conditional operator
AIM:
To a java program to read 2 integers and find the largest
number using conditional operator.
PROGRAM:
class Larges
{
public static void main(String args[])
{
int a,b,c;
a=[Link](args[0]);
b=[Link](args[1]);
c=a>b?a:b;
[Link]("The Largest Value="+c);
}
}
OUTPUT:
>java Largest 10 20

The Largest Value=20

RESULT:
Thus the program to two read integers and finding the
largest number using conditional operator was verified
successfully.
3).Write a java program to implement command line
Arguments.
AIM:
To implementing the java program that displays the
values passed through command line arguments.
PROGRAM:

class Sample
{
public static void main(String[] args)
{
[Link] (args[0]);
}
}
OUTPUT:
>javac [Link]
>java Sample CSE
CSE

RESULT:
Thus the java program that displays the values passed
through command line arguments is verified successfully.
4).Write a java program to find the SUM and AVERAGE
of your Tenth Standard marks.
AIM:
To write a java program to find the sum and average of tenth
standard marks.

PROGRAM:
class SumAvg
{
public static void main(String args[])
{
int i,n,sum=0;
float avg=0;
int mark[]={70,80,100,90,95};
n=[Link];
for (i=0;i<n;i++)
sum=sum+mark[i];
[Link]("Sum of 10th Mark is=" +sum);
avg=sum/n;
[Link]("The average is=" +avg);
}
}
OUTPUT:

>>javac [Link]
>>java SumAvg
Sum of 10th Mark is=435
The average is=87.0

RESULT:
Thus the java program for finding sum and average marks is
verified successfully.

You might also like