In: Computer Science
A Java program that solves a real-world problem The remaining amount (balance) for a prepaid cellular phone, is computed by subtracting the cost of the phone usage from the original phone load. The phone usage is based only on the total cost of text messages and phone calls. The cost of text messages is determined from the number of text messages sent and the cost of phone calls is determined from the number of minutes of calls made. ● Based from the data, write a java program that would compute for the remaining balance on the cellphone load of a subscriber. Let him enter values for the cellphone load, cost per text, cost per minute, number per messages and calls in minutes. ● From the subscriber’s inputs, your java program should be able to display the cost of messages, cost of calls, total usage and remaining balance of the cellphone load. Formula Hint: Use the concept of addition, subtraction and multiplication Depicted below are sample outputs when the program is executed.?
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
// Cellphone.java
import java.util.Scanner;
public class Cellphone {
public static void main(String[] args) {
// Declaring constants
final double CHARGES_PER_MINUTE =
0.60;
final double CHARGES_PER_TEXT =
0.10;
/*
* Declaring variables
*/
double balance, usageCost = 0.0,
costOfMessages = 0.0, costOfCalls = 0.0;
int noOfTexts, noOfMins;
/*
* Creating an Scanner class object
which is used to get the inputs
* entered by the user
*/
Scanner sc = new
Scanner(System.in);
// Getting the input entered by
the user
System.out.print("Enter the balance
in cellphone :$");
balance = sc.nextDouble();
System.out.print("Enter no of
text messages sent :");
noOfTexts = sc.nextInt();
System.out.print("Enter no of
minutes used :");
noOfMins = sc.nextInt();
// Performning
calculations
costOfMessages=noOfTexts*CHARGES_PER_TEXT;
costOfCalls=noOfMins*CHARGES_PER_MINUTE;
usageCost=costOfMessages+costOfCalls;
balance-=usageCost;
// Displaying the output
System.out.printf("\nCost of Texts
:$%.2f\n",costOfMessages);
System.out.printf("Cost of Calls
:$%.2f\n",costOfCalls);
System.out.printf("Usage Cost
:$%.2f\n",usageCost);
System.out.printf("Remaining
Balance :$%.2f\n",balance);
}
}
========================================
========================================
Output:
=====================Could you plz rate me well.Thank You