Question

Assignment 8.3: Phone Chatbot (10 pts) For this programming assignment, we write a basic chatbot program....

Assignment 8.3: Phone Chatbot (10 pts)

  • For this programming assignment, we write a basic chatbot program.
  • For fun, try having a conversation with an online chatbot here or here.
  • Some sources estimate that 25% of customer services will be handled by Chatbots in 2020, vs. 2% in 2017 (1).
  • The chatbot we are designing must ask you the following questions:
  1. What is your name?
  2. What is your phone number?
  3. What is your phone plan?
  4. How many GB of data this month?
  • Just don't give the chatbot your credit card number! ?

Project Specifications

  • Write a chatbot program that interacts with the user as described in the Interaction section below to calculate a phone bill.
  • Name the source code file Phonebot.java and include all your code in this single file.
  • Be careful of the spelling, including capitalization, as you will lose points for a misspelled name. Naming is important in programming.
  • Interaction: Interact with the user with the following inputs in the order given (and no other input) as follows:
  • Name: open the conversation with a welcome and find out the user's name (String).
    • Reply with a greeting that displays the user's name, like "Thanks for calling RobuCast <user's name>!".
  • Phone: find out the user's phone number (String).
    • Reply with a statement like "Looking up phone number <phone number>...".
  • Plan: ask the user for their plan type entered as a basic, gold or unlimited
    • Reply by spelling out the full plan name, (basic package, gold members, unlimited plan)
  • Data: request user's data usage in Gigabytes (double).
    • Reply with a comment that restates the amount of data, such as "Wow, <amount> is a lot of data! You should upgrade."
  • Total: display the total bill and say goodbye to <user's name>.
  • The parenthesis show the required data types for the input. Make sure to restate the input where indicated by the word "reply" or angle brackets.
  • Assume the user enters only valid data.
  • The phone bill is based on the phone plan and the number of Gigabytes (GB) of data used per month. Here are the different plans:
    • Basic package: the $24.95 per month plan provides 2 GB of data. Additional data are $7.00 per Gigabyte.
    • Gold member plan: the $39.95 per month plan provides 5 GB of data. Additional data are $5.00 per Gigabyte.
    • Unlimited plan: the $59.95 per month plan provides unlimited data.
  • Hint: Assume that the user input will be one word responses at most. Use only input.next() statements in this program (no input.nextLine() statements).
  • Example Output: The following shows example outputs. Your program prompts and output does not have to exactly match mine.
  • Your program does need to reply to all input as stated in Interactions above, but you are free to give your chatbot a personality.
  • Make sure the inputs are in the correct order and that you restate the data entered by the user.
  • Otherwise, have fun with it!
  • When you are finished, upload your PhoneBot.java file to Canvas
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!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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 ==================================

Add a comment
Know the answer?
Add Answer to:
Assignment 8.3: Phone Chatbot (10 pts) For this programming assignment, we write a basic chatbot program....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

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

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

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

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

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

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

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

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

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

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

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT