SlideShare a Scribd company logo
1 of 9
Download to read offline
InternetService.java
import java.text.DecimalFormat;
import java.util.Scanner;
public class InternetService
{
public static void main(String[] args)
{
DecimalFormat df=new DecimalFormat("#.##");
//initialize variable
char packageType;
int time;
double totalCharges;
double packA;
double packB;
double packC;
// create an object for Scanner class
Scanner input = new Scanner(System.in);
// prompt the user to enter the package purchased
System.out.print(" Enter the package purchased: ");
packageType = input.next().charAt(0);
//prompt the user to enter the number of minutes used
System.out.print("Enter the number of minutes used: ");
time = input.nextInt();
//Calculate the bill amount of the particular month using the type of package and the number of
minutes.
//Then print results to the screen
switch(packageType)
{
case 'A':
//Calling the Method for Package A charges
totalCharges=calPackA(time);
//Displaying the package A charges.
System.out.println("For Package A: The total charges for this month is $" + totalCharges);
//Calling the Method for Package B charges
packB=calPackB(time);
//Calling the Method for Package C charges
packC=calPackC(time);
//If the package B is Less Than package A then display the difference amount
if(totalCharges>packB)
System.out.println("Amount of Money Package A customer would save, if he Purchased
Package B is:$"+df.format(totalCharges-packB));
//If the package C is Less Than package A then display the difference amount
if(totalCharges>packC)
System.out.println("Amount of Money Package A customer would save, if he Purchased
Package C is:$"+df.format(totalCharges-packC));
break;
case 'B':
//Calling the Method for Package B charges
totalCharges=calPackB(time);
//Displaying the package B charges.
System.out.println("For Package B: The total charges for this month is $"
+df.format(totalCharges));
//Calling the Method for Package C charges
packC=calPackC(time);
//If the package B is Less Than package A then display the difference amount
if(totalCharges>packC)
System.out.println("Amount of Money Package B customer would save, if he Purchased
Package C is:$"+df.format(totalCharges-packC));
break;
case 'C':
//Calling the Method for Package C charges
totalCharges=calPackC(time);
//Displaying the package C charges.
System.out.print("For Package C: The total charges for this month is $" + totalCharges);
break;
default:
System.out.println(" The package should be A or B or C.");
}
}
/*This method will calculate the total Charges for Package C
* Params:Time
* Return:total charges of type double
*/
private static double calPackC(int time) {
double totalCharges = 69.99;
return totalCharges;
}
/*This method will calculate the total Charges for Package B
* Params:Time
* Return:total charges of type double
*/
private static double calPackB(int time) {
double totalCharges=0.0;
if(time <= 900)
totalCharges = 59.99;
else
totalCharges = 59.99 + (0.40 * (time - 900));
return totalCharges;
}
/*This method will calculate the total Charges for Package A
* Params:Time
* Return:total charges of type double
*/
private static double calPackA(int time) {
double totalCharges=0.0;
if(time <= 450)
totalCharges = 39.99;
else
totalCharges = 39.99 + (0.45 * (time - 450));
return totalCharges;
}
}
____________________________________________
Output1:
Enter the package purchased: A
Enter the number of minutes used: 440
For Package A:
The total charges for this month is $39.99
________________________________________________
output2:
Enter the package purchased: A
Enter the number of minutes used: 1000
For Package A:
The total charges for this month is $287.49
Amount of Money Package A customer would save, if he Purchased Package B is:$187.5
Amount of Money Package A customer would save, if he Purchased Package C is:$217.5
____________________________________________________
Output3:
Enter the package purchased: B
Enter the number of minutes used: 440
For Package B:
The total charges for this month is $59.99
____________________________________________________
Output4:
Enter the package purchased: B
Enter the number of minutes used: 1000
For Package B:
The total charges for this month is $99.99
Amount of Money Package B customer would save, if he Purchased Package C is:$30
____________________________________________
Solution
InternetService.java
import java.text.DecimalFormat;
import java.util.Scanner;
public class InternetService
{
public static void main(String[] args)
{
DecimalFormat df=new DecimalFormat("#.##");
//initialize variable
char packageType;
int time;
double totalCharges;
double packA;
double packB;
double packC;
// create an object for Scanner class
Scanner input = new Scanner(System.in);
// prompt the user to enter the package purchased
System.out.print(" Enter the package purchased: ");
packageType = input.next().charAt(0);
//prompt the user to enter the number of minutes used
System.out.print("Enter the number of minutes used: ");
time = input.nextInt();
//Calculate the bill amount of the particular month using the type of package and the number of
minutes.
//Then print results to the screen
switch(packageType)
{
case 'A':
//Calling the Method for Package A charges
totalCharges=calPackA(time);
//Displaying the package A charges.
System.out.println("For Package A: The total charges for this month is $" + totalCharges);
//Calling the Method for Package B charges
packB=calPackB(time);
//Calling the Method for Package C charges
packC=calPackC(time);
//If the package B is Less Than package A then display the difference amount
if(totalCharges>packB)
System.out.println("Amount of Money Package A customer would save, if he Purchased
Package B is:$"+df.format(totalCharges-packB));
//If the package C is Less Than package A then display the difference amount
if(totalCharges>packC)
System.out.println("Amount of Money Package A customer would save, if he Purchased
Package C is:$"+df.format(totalCharges-packC));
break;
case 'B':
//Calling the Method for Package B charges
totalCharges=calPackB(time);
//Displaying the package B charges.
System.out.println("For Package B: The total charges for this month is $"
+df.format(totalCharges));
//Calling the Method for Package C charges
packC=calPackC(time);
//If the package B is Less Than package A then display the difference amount
if(totalCharges>packC)
System.out.println("Amount of Money Package B customer would save, if he Purchased
Package C is:$"+df.format(totalCharges-packC));
break;
case 'C':
//Calling the Method for Package C charges
totalCharges=calPackC(time);
//Displaying the package C charges.
System.out.print("For Package C: The total charges for this month is $" + totalCharges);
break;
default:
System.out.println(" The package should be A or B or C.");
}
}
/*This method will calculate the total Charges for Package C
* Params:Time
* Return:total charges of type double
*/
private static double calPackC(int time) {
double totalCharges = 69.99;
return totalCharges;
}
/*This method will calculate the total Charges for Package B
* Params:Time
* Return:total charges of type double
*/
private static double calPackB(int time) {
double totalCharges=0.0;
if(time <= 900)
totalCharges = 59.99;
else
totalCharges = 59.99 + (0.40 * (time - 900));
return totalCharges;
}
/*This method will calculate the total Charges for Package A
* Params:Time
* Return:total charges of type double
*/
private static double calPackA(int time) {
double totalCharges=0.0;
if(time <= 450)
totalCharges = 39.99;
else
totalCharges = 39.99 + (0.45 * (time - 450));
return totalCharges;
}
}
____________________________________________
Output1:
Enter the package purchased: A
Enter the number of minutes used: 440
For Package A:
The total charges for this month is $39.99
________________________________________________
output2:
Enter the package purchased: A
Enter the number of minutes used: 1000
For Package A:
The total charges for this month is $287.49
Amount of Money Package A customer would save, if he Purchased Package B is:$187.5
Amount of Money Package A customer would save, if he Purchased Package C is:$217.5
____________________________________________________
Output3:
Enter the package purchased: B
Enter the number of minutes used: 440
For Package B:
The total charges for this month is $59.99
____________________________________________________
Output4:
Enter the package purchased: B
Enter the number of minutes used: 1000
For Package B:
The total charges for this month is $99.99
Amount of Money Package B customer would save, if he Purchased Package C is:$30
____________________________________________

More Related Content

Similar to InternetService.java import java.text.DecimalFormat; import jav.pdf

Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
Dillon Lee
 
Modify the Time classattached to be able to work with Date.pdf
Modify the Time classattached to be able to work with Date.pdfModify the Time classattached to be able to work with Date.pdf
Modify the Time classattached to be able to work with Date.pdf
aaseletronics2013
 
In this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdfIn this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdf
ivylinvaydak64229
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
annucommunication1
 
Pro.docx
Pro.docxPro.docx
Implementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in CImplementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in C
Kasun Ranga Wijeweera
 
The java Payroll that prompts user to enter hourly rate .pdf
  The java Payroll that prompts user to enter  hourly rate .pdf  The java Payroll that prompts user to enter  hourly rate .pdf
The java Payroll that prompts user to enter hourly rate .pdf
angelfashions02
 
The java program that prompts user to enter a string and .pdf
  The java program that prompts user to  enter a string and .pdf  The java program that prompts user to  enter a string and .pdf
The java program that prompts user to enter a string and .pdf
DEEPAKSONI562
 

Similar to InternetService.java import java.text.DecimalFormat; import jav.pdf (14)

Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
 
Whats new in ES2019
Whats new in ES2019Whats new in ES2019
Whats new in ES2019
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 
Modify the Time classattached to be able to work with Date.pdf
Modify the Time classattached to be able to work with Date.pdfModify the Time classattached to be able to work with Date.pdf
Modify the Time classattached to be able to work with Date.pdf
 
In this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdfIn this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdf
 
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHFC BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
 
Java doc Pr ITM2
Java doc Pr ITM2Java doc Pr ITM2
Java doc Pr ITM2
 
Class 6 2ciclo
Class 6 2cicloClass 6 2ciclo
Class 6 2ciclo
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
 
Pro.docx
Pro.docxPro.docx
Pro.docx
 
Implementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in CImplementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in C
 
The java Payroll that prompts user to enter hourly rate .pdf
  The java Payroll that prompts user to enter  hourly rate .pdf  The java Payroll that prompts user to enter  hourly rate .pdf
The java Payroll that prompts user to enter hourly rate .pdf
 
The java program that prompts user to enter a string and .pdf
  The java program that prompts user to  enter a string and .pdf  The java program that prompts user to  enter a string and .pdf
The java program that prompts user to enter a string and .pdf
 

More from anjaniar7gallery

This is social movement of British textile artisans in the early nin.pdf
This is social movement of British textile artisans in the early nin.pdfThis is social movement of British textile artisans in the early nin.pdf
This is social movement of British textile artisans in the early nin.pdf
anjaniar7gallery
 
TCP RFC 793 TCPIP (Transmission Control ProtocolInternet Proto.pdf
TCP  RFC 793 TCPIP (Transmission Control ProtocolInternet Proto.pdfTCP  RFC 793 TCPIP (Transmission Control ProtocolInternet Proto.pdf
TCP RFC 793 TCPIP (Transmission Control ProtocolInternet Proto.pdf
anjaniar7gallery
 
Please let me know if you need more clarification.final String pat.pdf
Please let me know if you need more clarification.final String pat.pdfPlease let me know if you need more clarification.final String pat.pdf
Please let me know if you need more clarification.final String pat.pdf
anjaniar7gallery
 
PasswordCheckerGUI.javaimport javafx.application.Application; im.pdf
PasswordCheckerGUI.javaimport javafx.application.Application; im.pdfPasswordCheckerGUI.javaimport javafx.application.Application; im.pdf
PasswordCheckerGUI.javaimport javafx.application.Application; im.pdf
anjaniar7gallery
 
Node for list storage. class Ndd { int data; Ndd next; N.pdf
Node for list storage. class Ndd { int data; Ndd next; N.pdfNode for list storage. class Ndd { int data; Ndd next; N.pdf
Node for list storage. class Ndd { int data; Ndd next; N.pdf
anjaniar7gallery
 
Laser ScanningLaser scanning is an emerging data acquisition techn.pdf
Laser ScanningLaser scanning is an emerging data acquisition techn.pdfLaser ScanningLaser scanning is an emerging data acquisition techn.pdf
Laser ScanningLaser scanning is an emerging data acquisition techn.pdf
anjaniar7gallery
 
Hardware refers to all of the physical parts of a computer system. F.pdf
Hardware refers to all of the physical parts of a computer system. F.pdfHardware refers to all of the physical parts of a computer system. F.pdf
Hardware refers to all of the physical parts of a computer system. F.pdf
anjaniar7gallery
 
Cost centersCost centers are Centers that incur costs for operati.pdf
Cost centersCost centers are Centers that incur costs for operati.pdfCost centersCost centers are Centers that incur costs for operati.pdf
Cost centersCost centers are Centers that incur costs for operati.pdf
anjaniar7gallery
 
a) Two domains are OD1 and OD2 domains. The common function of OD1 a.pdf
a) Two domains are OD1 and OD2 domains. The common function of OD1 a.pdfa) Two domains are OD1 and OD2 domains. The common function of OD1 a.pdf
a) Two domains are OD1 and OD2 domains. The common function of OD1 a.pdf
anjaniar7gallery
 

More from anjaniar7gallery (20)

Will be uploaded soonSolutionWill be uploaded soon.pdf
Will be uploaded soonSolutionWill be uploaded soon.pdfWill be uploaded soonSolutionWill be uploaded soon.pdf
Will be uploaded soonSolutionWill be uploaded soon.pdf
 
yeah...it is... you are 100 rightSolutionyeah...it is... you.pdf
yeah...it is... you are 100  rightSolutionyeah...it is... you.pdfyeah...it is... you are 100  rightSolutionyeah...it is... you.pdf
yeah...it is... you are 100 rightSolutionyeah...it is... you.pdf
 
trying to upload imageSolutiontrying to upload image.pdf
trying to upload imageSolutiontrying to upload image.pdftrying to upload imageSolutiontrying to upload image.pdf
trying to upload imageSolutiontrying to upload image.pdf
 
This is social movement of British textile artisans in the early nin.pdf
This is social movement of British textile artisans in the early nin.pdfThis is social movement of British textile artisans in the early nin.pdf
This is social movement of British textile artisans in the early nin.pdf
 
TCP RFC 793 TCPIP (Transmission Control ProtocolInternet Proto.pdf
TCP  RFC 793 TCPIP (Transmission Control ProtocolInternet Proto.pdfTCP  RFC 793 TCPIP (Transmission Control ProtocolInternet Proto.pdf
TCP RFC 793 TCPIP (Transmission Control ProtocolInternet Proto.pdf
 
Please let me know if you need more clarification.final String pat.pdf
Please let me know if you need more clarification.final String pat.pdfPlease let me know if you need more clarification.final String pat.pdf
Please let me know if you need more clarification.final String pat.pdf
 
sec-BuLi can be prepared by the reaction of sec-butyl halideswith li.pdf
sec-BuLi can be prepared by the reaction of sec-butyl halideswith li.pdfsec-BuLi can be prepared by the reaction of sec-butyl halideswith li.pdf
sec-BuLi can be prepared by the reaction of sec-butyl halideswith li.pdf
 
PasswordCheckerGUI.javaimport javafx.application.Application; im.pdf
PasswordCheckerGUI.javaimport javafx.application.Application; im.pdfPasswordCheckerGUI.javaimport javafx.application.Application; im.pdf
PasswordCheckerGUI.javaimport javafx.application.Application; im.pdf
 
pH + pOH = 14 pOH = 4.5 [OH-] = 10-4.5Fe(OH)2 --- Fe2+ + 2 O.pdf
pH + pOH = 14 pOH = 4.5 [OH-] = 10-4.5Fe(OH)2 --- Fe2+ + 2 O.pdfpH + pOH = 14 pOH = 4.5 [OH-] = 10-4.5Fe(OH)2 --- Fe2+ + 2 O.pdf
pH + pOH = 14 pOH = 4.5 [OH-] = 10-4.5Fe(OH)2 --- Fe2+ + 2 O.pdf
 
Node for list storage. class Ndd { int data; Ndd next; N.pdf
Node for list storage. class Ndd { int data; Ndd next; N.pdfNode for list storage. class Ndd { int data; Ndd next; N.pdf
Node for list storage. class Ndd { int data; Ndd next; N.pdf
 
Laser ScanningLaser scanning is an emerging data acquisition techn.pdf
Laser ScanningLaser scanning is an emerging data acquisition techn.pdfLaser ScanningLaser scanning is an emerging data acquisition techn.pdf
Laser ScanningLaser scanning is an emerging data acquisition techn.pdf
 
Importance of planning to the practice of managementSolutionIm.pdf
Importance of planning to the practice of managementSolutionIm.pdfImportance of planning to the practice of managementSolutionIm.pdf
Importance of planning to the practice of managementSolutionIm.pdf
 
Hardware refers to all of the physical parts of a computer system. F.pdf
Hardware refers to all of the physical parts of a computer system. F.pdfHardware refers to all of the physical parts of a computer system. F.pdf
Hardware refers to all of the physical parts of a computer system. F.pdf
 
Events after the reporting period are those events favorable and unf.pdf
Events after the reporting period are those events favorable and unf.pdfEvents after the reporting period are those events favorable and unf.pdf
Events after the reporting period are those events favorable and unf.pdf
 
D is correctSolutionD is correct.pdf
D is correctSolutionD is correct.pdfD is correctSolutionD is correct.pdf
D is correctSolutionD is correct.pdf
 
Cost centersCost centers are Centers that incur costs for operati.pdf
Cost centersCost centers are Centers that incur costs for operati.pdfCost centersCost centers are Centers that incur costs for operati.pdf
Cost centersCost centers are Centers that incur costs for operati.pdf
 
Calcium Phosphate is a slightly soluble salt. Here isthe equation fo.pdf
Calcium Phosphate is a slightly soluble salt. Here isthe equation fo.pdfCalcium Phosphate is a slightly soluble salt. Here isthe equation fo.pdf
Calcium Phosphate is a slightly soluble salt. Here isthe equation fo.pdf
 
c.250Solutionc.250.pdf
c.250Solutionc.250.pdfc.250Solutionc.250.pdf
c.250Solutionc.250.pdf
 
#! usrbinpython def Flatten(list) newList = [] for i in ra.pdf
#! usrbinpython def Flatten(list) newList = [] for i in ra.pdf#! usrbinpython def Flatten(list) newList = [] for i in ra.pdf
#! usrbinpython def Flatten(list) newList = [] for i in ra.pdf
 
a) Two domains are OD1 and OD2 domains. The common function of OD1 a.pdf
a) Two domains are OD1 and OD2 domains. The common function of OD1 a.pdfa) Two domains are OD1 and OD2 domains. The common function of OD1 a.pdf
a) Two domains are OD1 and OD2 domains. The common function of OD1 a.pdf
 

Recently uploaded

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Recently uploaded (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 

InternetService.java import java.text.DecimalFormat; import jav.pdf

  • 1. InternetService.java import java.text.DecimalFormat; import java.util.Scanner; public class InternetService { public static void main(String[] args) { DecimalFormat df=new DecimalFormat("#.##"); //initialize variable char packageType; int time; double totalCharges; double packA; double packB; double packC; // create an object for Scanner class Scanner input = new Scanner(System.in); // prompt the user to enter the package purchased System.out.print(" Enter the package purchased: "); packageType = input.next().charAt(0); //prompt the user to enter the number of minutes used System.out.print("Enter the number of minutes used: "); time = input.nextInt(); //Calculate the bill amount of the particular month using the type of package and the number of minutes. //Then print results to the screen switch(packageType) { case 'A': //Calling the Method for Package A charges
  • 2. totalCharges=calPackA(time); //Displaying the package A charges. System.out.println("For Package A: The total charges for this month is $" + totalCharges); //Calling the Method for Package B charges packB=calPackB(time); //Calling the Method for Package C charges packC=calPackC(time); //If the package B is Less Than package A then display the difference amount if(totalCharges>packB) System.out.println("Amount of Money Package A customer would save, if he Purchased Package B is:$"+df.format(totalCharges-packB)); //If the package C is Less Than package A then display the difference amount if(totalCharges>packC) System.out.println("Amount of Money Package A customer would save, if he Purchased Package C is:$"+df.format(totalCharges-packC)); break; case 'B': //Calling the Method for Package B charges totalCharges=calPackB(time); //Displaying the package B charges. System.out.println("For Package B: The total charges for this month is $" +df.format(totalCharges)); //Calling the Method for Package C charges packC=calPackC(time); //If the package B is Less Than package A then display the difference amount if(totalCharges>packC) System.out.println("Amount of Money Package B customer would save, if he Purchased
  • 3. Package C is:$"+df.format(totalCharges-packC)); break; case 'C': //Calling the Method for Package C charges totalCharges=calPackC(time); //Displaying the package C charges. System.out.print("For Package C: The total charges for this month is $" + totalCharges); break; default: System.out.println(" The package should be A or B or C."); } } /*This method will calculate the total Charges for Package C * Params:Time * Return:total charges of type double */ private static double calPackC(int time) { double totalCharges = 69.99; return totalCharges; } /*This method will calculate the total Charges for Package B * Params:Time * Return:total charges of type double */ private static double calPackB(int time) { double totalCharges=0.0; if(time <= 900)
  • 4. totalCharges = 59.99; else totalCharges = 59.99 + (0.40 * (time - 900)); return totalCharges; } /*This method will calculate the total Charges for Package A * Params:Time * Return:total charges of type double */ private static double calPackA(int time) { double totalCharges=0.0; if(time <= 450) totalCharges = 39.99; else totalCharges = 39.99 + (0.45 * (time - 450)); return totalCharges; } } ____________________________________________ Output1: Enter the package purchased: A Enter the number of minutes used: 440 For Package A: The total charges for this month is $39.99 ________________________________________________ output2: Enter the package purchased: A Enter the number of minutes used: 1000 For Package A: The total charges for this month is $287.49 Amount of Money Package A customer would save, if he Purchased Package B is:$187.5 Amount of Money Package A customer would save, if he Purchased Package C is:$217.5 ____________________________________________________ Output3: Enter the package purchased: B Enter the number of minutes used: 440
  • 5. For Package B: The total charges for this month is $59.99 ____________________________________________________ Output4: Enter the package purchased: B Enter the number of minutes used: 1000 For Package B: The total charges for this month is $99.99 Amount of Money Package B customer would save, if he Purchased Package C is:$30 ____________________________________________ Solution InternetService.java import java.text.DecimalFormat; import java.util.Scanner; public class InternetService { public static void main(String[] args) { DecimalFormat df=new DecimalFormat("#.##"); //initialize variable char packageType; int time; double totalCharges; double packA; double packB; double packC; // create an object for Scanner class Scanner input = new Scanner(System.in); // prompt the user to enter the package purchased System.out.print(" Enter the package purchased: ");
  • 6. packageType = input.next().charAt(0); //prompt the user to enter the number of minutes used System.out.print("Enter the number of minutes used: "); time = input.nextInt(); //Calculate the bill amount of the particular month using the type of package and the number of minutes. //Then print results to the screen switch(packageType) { case 'A': //Calling the Method for Package A charges totalCharges=calPackA(time); //Displaying the package A charges. System.out.println("For Package A: The total charges for this month is $" + totalCharges); //Calling the Method for Package B charges packB=calPackB(time); //Calling the Method for Package C charges packC=calPackC(time); //If the package B is Less Than package A then display the difference amount if(totalCharges>packB) System.out.println("Amount of Money Package A customer would save, if he Purchased Package B is:$"+df.format(totalCharges-packB)); //If the package C is Less Than package A then display the difference amount if(totalCharges>packC) System.out.println("Amount of Money Package A customer would save, if he Purchased Package C is:$"+df.format(totalCharges-packC)); break; case 'B':
  • 7. //Calling the Method for Package B charges totalCharges=calPackB(time); //Displaying the package B charges. System.out.println("For Package B: The total charges for this month is $" +df.format(totalCharges)); //Calling the Method for Package C charges packC=calPackC(time); //If the package B is Less Than package A then display the difference amount if(totalCharges>packC) System.out.println("Amount of Money Package B customer would save, if he Purchased Package C is:$"+df.format(totalCharges-packC)); break; case 'C': //Calling the Method for Package C charges totalCharges=calPackC(time); //Displaying the package C charges. System.out.print("For Package C: The total charges for this month is $" + totalCharges); break; default: System.out.println(" The package should be A or B or C."); } } /*This method will calculate the total Charges for Package C * Params:Time * Return:total charges of type double */
  • 8. private static double calPackC(int time) { double totalCharges = 69.99; return totalCharges; } /*This method will calculate the total Charges for Package B * Params:Time * Return:total charges of type double */ private static double calPackB(int time) { double totalCharges=0.0; if(time <= 900) totalCharges = 59.99; else totalCharges = 59.99 + (0.40 * (time - 900)); return totalCharges; } /*This method will calculate the total Charges for Package A * Params:Time * Return:total charges of type double */ private static double calPackA(int time) { double totalCharges=0.0; if(time <= 450) totalCharges = 39.99; else totalCharges = 39.99 + (0.45 * (time - 450)); return totalCharges; } } ____________________________________________ Output1: Enter the package purchased: A Enter the number of minutes used: 440 For Package A:
  • 9. The total charges for this month is $39.99 ________________________________________________ output2: Enter the package purchased: A Enter the number of minutes used: 1000 For Package A: The total charges for this month is $287.49 Amount of Money Package A customer would save, if he Purchased Package B is:$187.5 Amount of Money Package A customer would save, if he Purchased Package C is:$217.5 ____________________________________________________ Output3: Enter the package purchased: B Enter the number of minutes used: 440 For Package B: The total charges for this month is $59.99 ____________________________________________________ Output4: Enter the package purchased: B Enter the number of minutes used: 1000 For Package B: The total charges for this month is $99.99 Amount of Money Package B customer would save, if he Purchased Package C is:$30 ____________________________________________