Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class called Salutations that prints various greetings and salutations. The class should have one instance variable, a String called name to represent the

Write a class called Salutations that prints various greetings and salutations. The class should have one instance variable, a String called name to represent the person to whom the salutations are directed. The class should have the following methods A constructor that takes a String to initialize name with public void addressLetter() public void signLetter() public void addressMemo() public void signMemo) . addressLetter should print "Dear name", where name is replaced by the value of the instance variable name

signLetter() should print "Sincerely, name" where name is replaced by the value of the instance variable name addressMemo should print "To whom it may concern" signMemo should print "Best, name where name is replaced by the value of the instance variable name . 1 public class Salutationstester 2- { public static void main(String[] args) 4 { // Test your class here 6 } 7 } public class Salutations 2- { 3 // Put your code here 4 } 5 In this exercise, you are going to make a sample bot conversation. At this point, we don't have too much that we can do, but you are going to ask the user for their name and then use that in the constructor for the bot. After that,

you are going to simulate a conversation

2.

. You will print questions to the console and answer them by calling methods from the Bot class. (You don't actually prompt the user for any information other then their name) When you are finished, your output should match the output below (with the exception of your name). Sample Output: Hello. What is your name? Kiara Hello Kiara! My name is Hal! How are you today! You can ask me about the weather, or how many feet are in a mile. I can even convert feet to meters! What's the weather like? Its always warm and dzy inside your computer! How many feet in a mile? There are 5280 feet in a mile. It was nice talking with you! Have a great day! Challenge:

The bot does have some additional commands included, but we haven't covered these topics yet. Can you figure out how to access some of these methods? 1 import java.util.Scanner; 2 3 public class BotTester 4- { public static void main(String[] args) { 6 7 } 8 } 1. public class Bot { 2 3 private String name; 4 5- public Bot (String yourName) { 6 name = your Name; 7 8 9 public void greeting({ 0 System.out.print("Hello '); 11 System.out.print(name); 12 System.out.println("! My name is Hall"); 13 System.out.println("How are you today!");

14 } 15 16 public void help() { 17 System.out.println("You can ask me about the weather, "); 18 System.out.println("or how many feet are in a mile."); 19 System.out.println("I can even convert feet to meters!"); 20 } 21 22 public void weather(){ 23 System.out.println("Its always warm and dry inside your computer!"); 24 } 25 26 - public void feetInMile() { System.out.println("There are 5280 feet in a mile."); } 29 30 - public void goodbye() { System.out.println("It was nice talking with you!"); System.out.println("Have a great day!");

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

More Books

Students also viewed these Programming questions