Question

In: Computer Science

A Java program that solves a real-world problem The remaining amount (balance) for a prepaid cellular...

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.?

Solutions

Expert Solution

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


Related Solutions

the prepaid balance in the prepaid insurance account represent the remaining balance of two year policy...
the prepaid balance in the prepaid insurance account represent the remaining balance of two year policy purchased in April 2010 trial balance unjusted 31 October 2011 prepaid insurance 9350 the office furniture was purchased in March 1 2010 and has estimated useful life of two years of use it is expected that the furniture will be worthless office furniture October 31 2011 unjusted trial balance 61440 what are   the adjustments t for this two transactions
Why airplanes in War World I was important to society and the problem it solves?
Why airplanes in War World I was important to society and the problem it solves?
Write a program in C++ that solves this problem Calculate the area and volume of a...
Write a program in C++ that solves this problem Calculate the area and volume of a sphere problem. Inside a for loop, vary the radius from 10 to 40  with a step or increment of 5 and calculate the area and volume Your radius will be equal to your loop counter. All calculations should have 2 decimal places, but the radius should have zero decimal places and any number of 1,000 or more should have a comma. Print the radius, area,...
This exercise requires designing a program which solves the problem described in the problem statement below....
This exercise requires designing a program which solves the problem described in the problem statement below. Provide comments in your pseudo-code and Java program as necessary. Your solution must include these components: UML Class diagram Flowchart Pseudo-code Program Coded Program Output Problem Statement Design a class named Pet, which should have the following fields: name: The name field holds the name of a pet. type: The type field hold the type of animal that a pet is (for example, “dog”,...
Write a Java program that solves a set of quadratic equations as per Requirement #1 (without...
Write a Java program that solves a set of quadratic equations as per Requirement #1 (without using global variables), and reads an integer number entered in the command line, as follows: > java program_name input_number and depending on the value of this number does the following: 1) If the number entered is positive, the program shall solve (running in a loop) as many quadratic equations of the following form, as the input_number tells: a * x2 + b * x...
prepaid insurance account has a balance of 9350 remaining in October 31 2011 of two year...
prepaid insurance account has a balance of 9350 remaining in October 31 2011 of two year policy purchased in April 2010 the calculation was like that 9350 /17 550 prepaid insurance for year 550 *12 = 6600 and was the right amount but why they made it that way
Problem 1: In java Create a program to calculate interest rate and total balance - the...
Problem 1: In java Create a program to calculate interest rate and total balance - the program consists of (a) A class that encapsulates the interest rate and total balance calculation Constructor should accept initial balance and interest rate Methods: Returns interest rate Returns total balance Set interest rate Set initial balance (b) A test program that uses class from step (A) to perform the following: Set interest rate to 5% and initial balance to 1000 Print interest amount and...
Write a program that solves the Knapsack problem. Code to the following standards. Your source of...
Write a program that solves the Knapsack problem. Code to the following standards. Your source of items to put into the knapsack should consist of five randomly generated integers in the range of 1 to 20. Your knapsack can hold 20 lbs.
Write two Java programs ( Iterative and Recursive programs ) that solves Tower of Hanoi problem?use...
Write two Java programs ( Iterative and Recursive programs ) that solves Tower of Hanoi problem?use 4 disks and 3 bars
Needs to be in JAVA. Write a Java program that accepts the total amount of cars...
Needs to be in JAVA. Write a Java program that accepts the total amount of cars sold and total sales amount of a car salesperson for a given month. The salesperson’s paycheck is computed as follows: a. Every sales person gets 10% (commission) of total sales b. Sales totals greater than $50,000 get 5% of total sales amount c. 8 or more cars sold earns the salesperson an extra 3% Please remove 30% (taxes) of the gross pay and list...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT