Computer Science, asked by deepshikabloom3228, 1 month ago

Ananya purchased 5 pencils and 2 erasers at the cost of Rs 7 and Rs 5 respectively. Write the program
to calculate & display the total amount paid by ananya.

Answers

Answered by ItzMeSam35
2

//Keyboard Inputed Values

import java.util.*;

public class CostCalculations

{

public static void main (String args [])

{

double costofpencil = 1.4;

double costoferaser = 2.5;

Scanner sc=new Scanner (System.in);

System.out.print("Please Enter The Total Number Of Pencil Purchased : ");

int pencil = sc.nextInt();

System.out.print("Please Enter The Total Number Of Erasers Purchased : ");

int eraser = sc.nextInt();

double p = costofpencil * pencil ;

double e = costoferaser * eraser ;

double total = p + e ;

System.out.println("Total : "+total);

sc.close();

}

}

//According to the Question

import java.util.*;

public class CostCalculations

{

int cost_of_pencils = 7;

int cost_of_eraser = 5;

int total = cost_of_pencil + cost_of_eraser ;

System.out.println("Total : "+total);

}

Similar questions