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

Assignment 3

Uploaded by

riddhimashetty28
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)
18 views

Assignment 3

Uploaded by

riddhimashetty28
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/ 4

ASSIGNMENT-3

WRITE ALL DATATYPES WITH ITS SYNTAX

DATATYPES VARIABLES
int sc.nextInt();
float sc.nextFloat();
long sc.nextLong();
double sc.nextDouble();
char sc.next().charAt(0);
string sc.nextLIne();
boolean sc.nextBoolean

WRITE A PROGRAM TO CALCULATE AREA AND PERIMETER OF CIRLCE

import java.util.Scanner;

class areanandperimeter

public static void main(String args[])

Scanner sc=newScanner(System.in);

float radius,area,perimeter;

float pie=3.14;

System.out.println(“User enter value for radius”);

radius=sc.nextFloat();

area=pie*radius*radius;

perimeter=2*pie*radius;

System.out.println(“Area of circle”+area);

System.out.println(“Perimeter of circle is”+perimeter);


}

WRITE A PROGRAM TOACCEPT NAME,PERCENTAGE FROM USER AND PRINT


IT

import java.util.Scanner;

class details

public static void main(String agrs[])

Scanner sc=new Scanner(System.in);

String name;

int percentage;

System.out.println("Enter your name");

name=sc.nextLine();

System.out.println("Enter your percentage");

percentage=sc.nextInt();

System.out.println("the name is:"+name);

System.out.println("the percentage is:"+percentage);


}

Scanner sc=newScanner(System.in);

WRITE A PROGRAM TO SWAP NO.S W/O USING THIRD VARIABLE

import java.util.Scanner;

class swapwo

public static void main(String agrs[])

Scanner sc=new Scanner(System.in);

int a,b;

System.out.println("Enter the first no.");

a=sc.nextInt();
System.out.println("Enter the second no.");

b=sc.nextInt();

a=a+b;

b=a-b;

a=a-b;

System.out.println("The swapped value of a is:"+a);

System.out.println("The swapped value of b is:"+b);

%=quotient

/=remainder

You might also like