Assignment 8.3: Phone Chatbot (10 pts)
Project Specifications
Welcome to RobuCast. What is your name? jason Thanks for calling RobuCast Jason! What is your phone number? 555-2368 Looking up phone number 555-2368... What is your phone plan? (basic/gold/unlimited) basic Ah, the Basic package. How many GB of data this month? 5 Wow, 5 GB is a lot of data! Maybe you should upgrade. Your total bill is: $45.95. Thanks for calling RobuCast, Jason!
Welcome to RobuCast. What is your name? Polly Thanks for calling RobuCast Polly! What is your phone number? (669)221-6251 Looking up phone number (669)221-6251... What is your phone plan? (basic/gold/unlimited) gold Welcome Gold member. How many GB of data this month? 7 Wow, 7 GB is a lot of data! You should upgrade. Your total bill is: $49.95. Thanks for calling RobuCast, Polly Podcast!
Welcome to RobuCast. What is your name? Richie$Rich Thanks for calling RobuCast Richie$Rich! What is your phone number? 555-0144 Looking up phone number 555-0144... What is your phone plan? (basic/gold/unlimited) unlimited The Unlimited plan. How many GB of data this month? 10 Wow, 10 GB is a lot of data! Good thing you have the unlimited plan. Your total bill is: $59.95. Thanks for calling RobuCast, Richie$Rich!
Hello! I have written the code as you have requested for. I have explained the entire code within the comments of the code so that you can easily understand the code. I have also attached a screenshot of the output of the program for the given testcase .In case you have trouble understanding any part please do comment. I am always available for your help.
====================================Code begins here========================================
import java.io.*;
import java.util.Scanner; // Scanner class is used for reading
inputs from the keyboard
class Phonebot{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
/* I have defined a seperate print method for printing the output
onto the screen.
The print methods use method overloading. Method overloading means
that we can define multiple funcitons with the
same name but every function with the same name has a different
parameter type or a different number of parameters .
Also you might have noticed that I have used % symbol for
replacing the string with the variable. This % acts as a
placeholder
of the text. It is a very common method used for creating a
textfile or a document such as a bill which can be used to print in
a
hard copy format.
*/
print("Welcome to RobuCast. What is your name?");
String name = scan.next();
print("Thanks for calling RobuCast %!", name);
print("What is your phone number?");
String phoneNumber = scan.next();
print("Looking up phone number %", phoneNumber);
print("What is your phone plan? (basic/gold/unlimited)");
String phonePlan = scan.next();
print("Ah, the % package.", phonePlan);
print("How many GB of data this month? ");
double monthlyData = scan.nextDouble();
print("Wow, % GB is a lot of data! Maybe you should upgrade.",
monthlyData);
double bill = calculateBill(phonePlan, monthlyData);
print("Your total bill is: $%.", bill);
}
public static void print(String str){
System.out.println(str);
}
public static void print(String str, String placeHolder){
/*
We are selecting only the first letter in the string and converting
it to an uppercase letter. We could have done
this by adding +65 to the character to convert it to upper case but
using the predefined function looked much cleaner.
And as you can see I am using replace function to replace the
placeholder with the variable
*/
placeHolder = placeHolder.substring(0, 1).toUpperCase() +
placeHolder.substring(1);
String newStr = str.replace("%", placeHolder);
System.out.println(newStr);
}
public static void print(String str, double placeHolder){
String newStr = str.replace("%",
String.valueOf(placeHolder));
System.out.println(newStr);
}
public static double calculateBill(String plan, double
monthlyData){
/*
I could have used switch case for calculating bill but it looked a
bit ugly when I wrote the code So
I have chose to use if else statements. This can be even more
further reduced by defining their individual functions but
since there are only 3 plans and not much computation is required I
have used on if else. You can change it to use functions
if you want to
*/
if(plan.equalsIgnoreCase("basic")){
double additionalData = monthlyData - 2;
double bill = 24.95 + additionalData * 7;
return bill;
} else if(plan.equalsIgnoreCase("gold")){
double additionalData = monthlyData - 5;
double bill = 39.95 + additionalData * 5;
return bill;
} else if(plan.equalsIgnoreCase("unlimited")){
return 59.95;
}
return monthlyData;
}
}
===========================================Code ends here ==================================
Assignment 8.3: Phone Chatbot (10 pts) For this programming assignment, we write a basic chatbot program....
C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...
Write a C++ program that uses: .selection constructs (if, if else, and switch) .multiway branches .looping constructs (do and while loops) .Boolean expressions, bool and char types. 1. Develop a program that calculates charges for an Internet provider. The cost is determined by the amount of data used and the consumer plan. Package B (basic) is the most affordable if you plan on using < 20GB (20,000MB), however, if you consume more than 20GB (20,000MB) you are charged for each...
Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required. Project Requirements Develop a text...
User Profiles Write a program that reads in a series of customer information -- including name, gender, phone, email and password -- from a file and stores the information in an ArrayList of User objects. Once the information has been stored, the program should welcome a user and prompt him or her for an email and password The program should then use a linearSearch method to determine whether the user whose name and password entered match those of any of...
Using C programming REQUIREMENTS: This program is a letter guessing game where a simple Al opponent generates a secret letter for the user to guess. The user must be able to take turns guessing the secret letter, with the Al responding to the user's guesses. After successfully guessing, the user must be allowed to play again. The Al must count how many turns the user has taken. Here is an example of a game in progress where the human user...
== Programming Assignment == For this assignment you will write a program that reads in the family data for the Martian colonies and stores that data in an accessible database. This database allows for a user to look up a family and its immediate friends. The program should store the data in a hashtable to ensure quick access time. The objective of this assignment is to learn how to implement and use a hashtable. Since this is the objective, you...
CIST 1305 – Program Design and Development Chapter 4 Assignment #7 [Decisions/If Statements & Loops] (50 Points) Please do the following exercises: Pastoral College is a small college in the Midwest. Design the pseudo-code for a program that accepts a student name, major field of study, and grade point average. Display a student’s data with the message “Dean’s list” if the student’s grade point average is above 3.5, “Academic probation” if the grade point average is below 2.0, and no...
In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item): Name Price Egg (cooked to order)...
Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...
programming language: C++ *Include Line Documenatations* Overview For this assignment, write a program that will simulate a game of Roulette. Roulette is a casino game of chance where a player may choose to place bets on either a single number, the colors red or black, or whether a number is even or odd. (Note: bets may also be placed on a range of numbers, but we will not cover that situation in this program.) A winning number and color is...