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

Assessment 3 Programs Solution

Uploaded by

Shalvv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Assessment 3 Programs Solution

Uploaded by

Shalvv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Assessment 3

Program 1

import java.util.*;
//To display relief fund
class Fund
{
public void main () throws Exception
{
Scanner sc = new Scanner (System.in)
System.out.println(“Enter gender M for male F for female”);
char g=(char)System.in.read();
System.out.println(“Enter age”);
int a=sc.nextInt();
int pay_amt=0;

if (g=='M' || g=='m')
{
if(a>25 && a<=35)
{
int pay_amt=4*350;
}
else if(a<35)
{
pay_amt= (4*350) +25;
}
}//if ends
else if (g=='F' || g=='f')
{
if (a>20 && a<=30)
{
pay_amt=4*375;
}
else if(a>30)
{
pay_amt=(4*375) +35;
}
}//else if ends
else
{
System.out.println(“Invalid entry”);
}
System.out.println("Gender is"+g);
System.out.println("Age is="+a);
System.out.println("Monthly Fund is"+ pay_amt);
}//main ends
}//class ends

Program 2

import java.util.*;
// To calculate the maturity amount of bank;
class Amt
{
public void main()
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter 1 for Term Deposit");
System.out.println("Enter 2 for Recurring Deposit")
System.out.print("Enter your choice ");
int ch = sc.nextInt();
double p = 0.0;
double r = 0.0;
double a = 0.0;
int n = 0;

switch (ch)
{
case 1:
System.out.print("Enter Principle amount: ");
p = sc.nextDouble();
System.out.print("Enter rate of interest: ");
r = sc.nextDouble();
System.out.print("Enter time in years: ");
n = sc.nextInt()
a = p * Math.pow((1 + r / 100), n);
System.out.println("Maturity amount = " + a);
break;

case 2:
System.out.print("Enter Monthly Installment ");
p = sc.nextDouble();
System.out.print("Enter rate of interest ");
r = sc.nextDouble();
System.out.print("Enter time in months ");
n = sc.nextInt();
a = p * n + p * ((n * (n + 1)) / 2.0) * (r / 100.0) + (1 / 12.0);
System.out.println("Maturity amount = " + a);
break;

default:
System.out.println("Invalid choice");
}//switch ends
}//main ends
}//class ends

Program 3

import java.util.*;
class Movie
{
public void main()
{
Scanner sc= new Scanner (System.in);
System.out.println("Enter Title of Movie” );
String title = sc.nextLine();
System.out.println("Enter Year of Movie ");
int year = sc.nextInt();
System.out.println("Enter Rating of Movie ");
double rating = sc.nextDouble();
System.out.println(“MOVIE TITLE:”+title);
if (rating <= 2.0)
System.out.println("Flop");
else if (rating >=2.1 && rating <= 3.4)
System.out.println ("Semi-Hit");
else if (rating >= 3.4 && rating <= 4.5)
System.out.println( "Hit");
else if (rating >= 4.6 && rating <= 5.0)
System.out.println("Super-Hit");
}//main ends
}//class ends

Program 4

import java.util.*;
//To perform the conversions
class Conversions
{
public void main ()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter 1 to convert kilometer to meter");
System.out.println("Enter 2 to convert Rupees to paisa");
System.out.println("Enter 3 to convert Centigrade to Fahrenheit");
System.out.println(“Enter 4 to covert Hours to seconds”)
System.out.println("Enter your choice");
int ch=sc.nextInt();

switch(ch)
{
case 1:
System.out.println(“Enter km”);
int km=sc.nextInt();
int m=km*1000;
System.out.println("The distance in meters="+m);
break;
case 2:
System.out.println(“Enter amount in rupees”);
double rs= sc.nextDouble();
double paise= 100*rs;
System.out.println("Amount in Paise: "+paise);
break;

case 3:
System.out.println(“Enter Centigrade”);
double c=sc.nextInt();
double f=(1.8*c) +32;
System.out.println("The temperature in fahrenheit="+f);
break;

case 4:
System.out.println(“Enter hr”);
int hr=sc.nextInt();
int sec=hr*60*60;
System.out.println("The time in seconds="+sec);
break;

default:
System.out.println("Invalid Choice");

}//switch ends
}//main ends
}//class ends

Program 5

import java.util.*;
//To calculate and display students details
class Stu_details
{
public void main()
{
Scanner sc = new Scanner(System.in);
System.out.println(“Enter name”);
String n= sc.nextLine();
System.out.println(“Enter roll no”);
int rno=sc.nextInt();
System.out.println(“Enter marks in 5 subjects”);
int S1=sc.nextInt();
int S2=sc.nextInt();
int S3=sc.nextInt();
int S4=sc.nextInt();
int S5=sc.nextInt();
int marks= S1+S2+S3+S4+S5;
double per= (marks/500.0) *100;
System.out.println("Total marks"+marks);
System.out.println("Percentage="+per);
if(per>=90)
{
System.out.println("Stream="+Science with Computers");
}
else if(per>= 80 && per<= 89)
{
System.out.println("Stream="+Science without Computers");
}
else if (per<=70 && per>=79)
{
System.out.println("Stream Commerce with Maths");
}
else if (per<=60 && per>=69)
{
System.out.println("Stream="+Commerce without Maths");
else
{
System.out.println("Stream="+Eco and EVS");
}
}//main ends
}//class ends

You might also like