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

Pankaj

The document contains 5 questions related to Java programming. Each question provides sample input/output and code to solve the problem. Question 1 asks to write a program to calculate the amount to be paid by a customer for a mobile phone with a printed price, 10% discount, and 9% GST on the remaining amount. Question 2 asks to write a program that calculates money spent on food, rent, miscellaneous and savings based on percentages of a monthly salary input.

Uploaded by

Anand Lal Roy
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)
93 views5 pages

Pankaj

The document contains 5 questions related to Java programming. Each question provides sample input/output and code to solve the problem. Question 1 asks to write a program to calculate the amount to be paid by a customer for a mobile phone with a printed price, 10% discount, and 9% GST on the remaining amount. Question 2 asks to write a program that calculates money spent on food, rent, miscellaneous and savings based on percentages of a monthly salary input.

Uploaded by

Anand Lal Roy
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/ 5

Question 1

A shopkeeper offers 10% discount on the printed price of a mobile phone. However,

a customer has to pay 9% GST on the remaining amount. Write a program in Java to

calculate the amount to be paid by the customer taking printed price as an input.

import java.util.*;

public class MobilePrice

public static void main(String args[])

Scanner xx = new Scanner(System.in);

int mp;

double dis=0.00,gst=0.00,cm=0.00,ra=0.00;

System.out.print("Enter Price Of the Mobile Rs. ");

mp=xx.nextInt();

dis=(double)mp*10/100;

ra=(double)mp-dis;

gst=(double)ra*9/100;

cm=ra+gst;

System.out.println("Cost of Mobile Rs. "+cm);

}
Question 2

A man spends (1/2) of his salary on food, (1/15) on rent, (1/10) on miscellaneous. Rest of the

salary is his saving. Write a program to calculate and display the following:

1. money spent onfood

2. money spent onrent

3. money spent onmiscellaneous

4. moneysaved

Take the salary as an input.

import java.util.*;

public class Expenditure

public static void main(String args[])

Scanner xx = new Scanner(System.in);

int s;

double f,r,m,sv;

System.out.print("Enter Salary For the Month ");

s=xx.nextInt();

f=(double).5*s;

r=(double).067*s;

m=(double).1*s;

sv=(double)s-(f+r+m);

System.out.println("Salary Spent on Food of 1/2 thof Salary Rs. "+f);

System.out.println("Salary Spent on Rent of 1/15 thof Salary Rs. "+r);

System.out.println("Salary Spent on Misc. of 1/10 th of Salary Rs. "+m);

System.out.println("Total Spent"+(f+r+m)+" Out of Rs. "+s);

System.out.println("Saving Rs. "+sv);

}
Question 3

Write a program to input time in seconds. Display the time after converting them into hours,

minutes and seconds.

Sample Input: Time in seconds: 5420

Sample Output: 1 Hour 30 Minutes 20 Seconds

import java.util.*;

public class CovertHrsMisSec

public static void main(String args[])

Scanner xx = new Scanner(System.in);

int s,rs,m1,h,m;

System.out.print("Enter Time in Seconds ");

s=xx.nextInt();

m1=s/60;

rs=s%60;

h=m1/60;

m=m1%60;

System.out.print( h+" Hour " +m +" Minutes " + rs+" Seconds");

}
Question 4

Write a program to input two unequal numbers. Display the numbers after swapping their

values in the variables without using a third variable.

Sample Input: a = 76, b = 65

Sample Output: a = 65, b = 76

import java.util.*;

public class Swapping

public static void main(String args[])

Scanner xx = new Scanner(System.in);

int a,b;

System.out.print("Enter First Number");

a=xx.nextInt();

System.out.print("Enter First Number");

b=xx.nextInt();

System.out.println("Value of A Before Swapping"+a);

System.out.println("Value of B Before Swapping"+b);

a=a*b;

b=a/b;

a=a/b;

System.out.println("Value of A After Swapping "+a);

System.out.println("Value of B After Swapping "+b);

}
Question 5

A certain amount of money is invested for 3 years at the rate of 6%, 8% and 10% per annum

compounded annually. Write a program to calculate:

1. the amount after 3years.

2. the compound interest after 3years.

Accept certain amount of money (Principal) as an input.

Hint: A = P * (1 + (R1 / 100))T

* (1 + (R2 / 100))T * (1 + (R3 / 100))T and CI = A – P

import java.util.*;

public class CompoundInterest

public static void main(String args[])

Scanner xx = new Scanner(System.in);

double p;

double a1=0.00,a2=0.00,a3=0.00,ci=0.00;

System.out.print("Enter Principal Amount Rs. ");

p=xx.nextDouble();

a1=p*106/100;

a2=a1*108/100;

a3=a2*110/100;

ci=a3-p;

System.out.println("Compound Interest After 3 Years Rs. "+ci);

You might also like