write a program in Java that determines the value of the coins in a jar and prints the total in rupees and paise. Read integer values that represent the number of 10rs coins, 5rs coins, 2rs coins, 1rs coins, 50 paise coins, 25 paise coins, 20 paise coins, 10 paise coins and 5 paise coins.
Answers
Answered by
13
import java.util.Scanner;
public class JAVA_Program
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of 10 Rupees Coins: ");
int n1 = sc.nextInt();
System.out.print("Enter the number of 5 Rupees Coins: ");
int n2 = sc.nextInt();
System.out.print("Enter the number of 2 Rupees Coins: ");
int n3 = sc.nextInt();
System.out.print("Enter the number of 1 Rupee Coins: ");
int n4 = sc.nextInt();
System.out.print("Enter the number of 50 Paise Coins: ");
int n5 = sc.nextInt();
System.out.print("Enter the number of 25 Paise Coins: ");
int n6 = sc.nextInt();
System.out.print("Enter the number of 20 Paise Coins: ");
int n7 = sc.nextInt();
System.out.print("Enter the number of 10 Paise Coins: ");
int n8 = sc.nextInt();
System.out.print("Enter the number of 5 Paise Coins: ");
int n9 = sc.nextInt();
int sr = (10*n1)+(5*n2)+(2*n3)+n4;
int sp = (50*n5)+(25*n6)+(20*n7)+(10*n8)+(5*n9);
sr += sp/100;
sp = sp%100;
System.out.println("Jar contains "+sr+" Rupees "+sp+" Paise");
}
}
public class JAVA_Program
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of 10 Rupees Coins: ");
int n1 = sc.nextInt();
System.out.print("Enter the number of 5 Rupees Coins: ");
int n2 = sc.nextInt();
System.out.print("Enter the number of 2 Rupees Coins: ");
int n3 = sc.nextInt();
System.out.print("Enter the number of 1 Rupee Coins: ");
int n4 = sc.nextInt();
System.out.print("Enter the number of 50 Paise Coins: ");
int n5 = sc.nextInt();
System.out.print("Enter the number of 25 Paise Coins: ");
int n6 = sc.nextInt();
System.out.print("Enter the number of 20 Paise Coins: ");
int n7 = sc.nextInt();
System.out.print("Enter the number of 10 Paise Coins: ");
int n8 = sc.nextInt();
System.out.print("Enter the number of 5 Paise Coins: ");
int n9 = sc.nextInt();
int sr = (10*n1)+(5*n2)+(2*n3)+n4;
int sp = (50*n5)+(25*n6)+(20*n7)+(10*n8)+(5*n9);
sr += sp/100;
sp = sp%100;
System.out.println("Jar contains "+sr+" Rupees "+sp+" Paise");
}
}
QGP:
You are welcome :)
Similar questions