0% found this document useful (0 votes)
7 views

Siya Rawat[1] Java Pratical File

The document contains Java programs for three tasks: summing an integer and a float, swapping two integers, and checking if a number is prime. Each program includes user input and output statements to display results. The code snippets demonstrate basic programming concepts such as variable declaration, user input handling, and control flow.

Uploaded by

sparshbisht24
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 views

Siya Rawat[1] Java Pratical File

The document contains Java programs for three tasks: summing an integer and a float, swapping two integers, and checking if a number is prime. Each program includes user input and output statements to display results. The code snippets demonstrate basic programming concepts such as variable declaration, user input handling, and control flow.

Uploaded by

sparshbisht24
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
You are on page 1/ 3

1. WAP to sum of two numbers.

import java.util.Scanner;
class Sum {
public static void main(String[] args)
{
Scanner user = new Scanner(System.in);
int a;
float b,sum;
System.out.println("Enter integer number:");
a=user.nextInt();
System.out.println("Enter float number:");
b=user.nextFloat();
sum = b + a;
System.out.println("Sum is :" + sum);
}
}

OUTPUT:
2. WAP to swap two numbers.
import java.util.Scanner;
class Swapping{
public static void main(String[] args)
{
Scanner user = new Scanner(System.in);
int a,b,c;
System.out.println("Enter the value of a:");
a=user.nextInt();
System.out.println("Enter the value of b:");
b=user.nextInt();
System.out.println("value at a is "+a);
System.out.println("value at b is" +b);
c=a;
a=b;
b=c;
System.out.println("value at a after swap is "+a);
System.out.println("value at b after swap is" +b);
}
}

OUTPUT:
3. WAP to print to check whether the given number is prime or not.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy