Questions
IN JAVA Laboratory 3: Ice Cream! Download Lab03.zip from ilearn and extract it into your working...

IN JAVA

Laboratory 3: Ice Cream!

Download Lab03.zip from ilearn and extract it into your working lab 3 directory

In this lab, you will be writing a complete class from scratch, the IceCreamCone class. You will also write a driver to interact with a user and to test all of the IceCreamCone methods.

Lab:

• Cone
• Ice Cream

o Flavor

o Topping

• Ice Cream Cone

• Driver

Part I: Cone

An ice cream cone has two main components, the flavor of ice cream and the type of cone. Write a Cone class that takes an integer in its constructor. Let a 1 represent a sugar cone, let a 2 represent a waffle cone, and let a 3 represent a cup. It will help to use a private variable in order to keep track of the cone type amongst your methods. Make sure to set an invalid entry to a default cone (the choice of default is up to you). Write a method to return the price of the cone. The sugar cone is $0.59, the waffle cone is $0.79, and the cup is free. Write a toString() method to return a String indicating the type of cone that was selected.

Note: If you need a carriage return in a String, use "\r\n"

Part II: Ice Cream
Download the following files:

• Topping.java
o public double price() //toppings are $0.15 ("no topping" is free)

• Toppings.java //this file has the following public interface:
o public static Toppings getToppings() //singleton design pattern
o public int numToppings() //the number of different toppings
o public String listToppings() //list (and number) available toppingso public Topping getTopping(int index) //1-based

  • Flavor.java

  • Flavors.java //this file has the following public interface:

o public static Flavors getFlavors() //singleton design pattern
o public int numFlavors() //the number of different flavors
o public String listFlavors() //list (and number) available flavorso public Flavor getFlavor(int index) //1-based

Ice cream has a number of scoops, a flavor, and a topping. Write an IceCream constructor that accepts the number of scoops (up to 3), a Flavor object, and a Topping object. It will help to use private variables in order to keep track of the number of scoops, your flavor, and your topping amongst your methods. Set default values (up to you) if the input is invalid (make sure to protect against null). Write a method to return the price

(each scoop over 1 adds $0.75 to the cost of the ice cream) and a method to return a String listing the ice cream parameters selected.

Part III: Ice Cream Cone

Download the following file:

• Currency.class //this file has the following public interface:
o public static String formatCurrency(double val) //formats the double as a String representing US

currency

It will help to use private variables in order to keep track of your cone and ice cream amongst your methods. Use Currency.class to format the total price of the Ice Cream Cone.

Note: Without using the Currency class, it is possible to get final prices that are not quite correct, such as 3.5300000000000002.

The IceCreamCone is composed of the Cone and the IceCream. Write a constructor that accepts an IceCream

and a Cone (protect against null), a method to return the price (the base price is $1.99 plus any costs

associated with the components), and a method to return a String display of the ice cream cone ordered by the

user.

Part IV: Ice Cream Driver

Download the following file:

• Keyboard.class //this file has the following public interface:
o public static Keyboard getKeyboard() //singleton design patterno public int readInt(String prompt)
o public double readDouble(String prompt)
o public String readString(String prompt)

defensive programming

In addition to main, include the following methods in your driver:

This is

Write a driver to obtain the ice cream cone order from the user. Allow multiple ice cream cones to be ordered,

and keep a

running total

of the price of the ice cream cones. Of course, wait (loop) for the user to input valid

entries. Thus, you are checking for valid entries in the driver and in the constructor of your objects.

, although it results in some code duplication.

  1. public static Flavor getFlavorChoice() //look at the methods available in the Flavors class

  2. public static Topping getToppingChoice() //look at the methods available in the Toppings class

  3. public static int getScoopsChoice()

  4. public static Cone getConeChoice()

All of these methods take input from the user (using Keyboard.class) Example output included as a jpg in Lab03 files.
To compile: javac *.java

To run: java IceCreamDriver

You can also run your driver with my input file via: java IceCreamDriver < ice_cream.txt (or by running make.bat)

CURRENCY.JAVA

import java.text.DecimalFormat;

public class Currency
{
private final static DecimalFormat fmt = new DecimalFormat("#,##0.00");

public static String formatCurrency(double val)
{
String temp = "$" + fmt.format(val);
return temp;
}
}

TOPPING.JAVA


public enum Topping
{
nuts(0.15), m_and_ms(0.15), hot_fudge(0.15), oreo_cookies(0.15), no_topping(0.00);

private double toppingPrice;

private Topping(double price)
{
toppingPrice = price;
}

public double price()
{
return toppingPrice;
}
}

TOPPINGS.JAVA


public class Toppings
{
private static Toppings toppings = new Toppings();
private Topping[] all_toppings;

private Toppings()
{
all_toppings = Topping.values();
}

public static Toppings getToppings()
{
return toppings;
}

public int numToppings()
{
return all_toppings.length;
}

public String listToppings()
{
int index = 1;

//loop through the enumeration, listing the flavors
String topping_str = "";

for (Topping top : all_toppings)
{
topping_str += index + ". " + top.toString() + "\r\n";
index++;
}

return topping_str;
}

public Topping getTopping(int index) //1-based
{
int num_toppings = numToppings();
if (index < 1 || index > num_toppings)
{
index = 1;
}

return all_toppings[index - 1];
}
}

FLAVOR.JAVA


public enum Flavor
{
chocolate, vanilla, coffee, mint_chocolate_chip, almond_fudge, pistachio_almond,
pralines_and_cream, cherries_jubilee, oreo_cookies_and_cream, peanut_butter_and_chocolate,
chocolate_chip, very_berry_strawberry, rocky_road, butter_pecan, chocolate_fudge, french_vanilla,
nutty_coconut, truffle_in_paradise;
}

FLAVORS.JAVA


public class Flavors
{
private static Flavors flavors = new Flavors();
private Flavor[] all_flavors;

private Flavors()
{
all_flavors = Flavor.values();
}

public static Flavors getFlavors()
{
return flavors;
}

public int numFlavors()
{
return all_flavors.length;
}

public String listFlavors()
{
int index = 1;

//loop through the enumeration, listing the flavors
String flavor_str = "";

for (Flavor flavor : all_flavors)
{
flavor_str += index + ". " + flavor.toString() + "\r\n";
index++;
}

return flavor_str;
}

public Flavor getFlavor(int index)
{
int num_flavors = numFlavors();
if (index < 1 || index > num_flavors)
{
index = 1;
}

return all_flavors[index - 1];
}
}

KEYBOARD.JAVA

public class Keyboard
{
private static Keyboard kb = new Keyboard();

/** The SDK provided Scanner object, used to obtain keyboard input */
private java.util.Scanner scan;

private Keyboard()
{
scan = new java.util.Scanner(System.in);
}

public static Keyboard getKeyboard()
{
return kb;
}

/**
* Reads an integer from the keyboard and returns it.

* Uses the provided prompt to request an integer from the user.
*/
public int readInt(String prompt)
{
System.out.print(prompt);
int num = 0;

try
{
num = scan.nextInt();
readString(""); //clear the buffer
}
catch (java.util.InputMismatchException ime) //wrong type inputted
{
readString(""); //clear the buffer
num = 0;
}
catch (java.util.NoSuchElementException nsee) //break out of program generates an exception
{
readString(""); //clear the buffer
num = 0;
}
return num;
}

/**
* Reads a double from the keyboard and returns it.

* Uses the provided prompt to request a double from the user.
*/
public double readDouble(String prompt)
{
System.out.print(prompt);
double num = 0.0;

try
{
num = scan.nextDouble();
readString(""); //clear the buffer
}
catch (java.util.InputMismatchException ime)
{
readString(""); //clear the buffer
num = 0;
}
catch (java.util.NoSuchElementException nsee)
{
readString(""); //clear the buffer
num = 0;
}

return num;
}

/**
* Reads a line of text from the keyboard and returns it as a String.

* Uses the provided prompt to request a line of text from the user.
*/
public String readString(String prompt)
{
System.out.print(prompt);
String str = "";

try
{
str = scan.nextLine();
}
catch (java.util.NoSuchElementException nsee)
{
readString(""); //clear the buffer
str = "";
}

return str;
}
}

In: Computer Science

The five basic components of promotion include advertising, sales promotions, social media, publicity, and personal selling....

The five basic components of promotion include advertising, sales promotions, social media, publicity, and personal selling. All five components of the retailer’s promotion mix need to be managed from a total systems perspective.

All non-essential retail businesses are closed due to the COVID-19 lockdown. At some point (hopefully in the near future) we will return to normal and these businesses will reopen.

While these businesses will be receiving financial support from the government, many are going to be in a tight situation, and fighting for every dollar when the doors finally open. So, they will need to rely on sales promotion, publicity, social media and personal selling to succeed. Those that don’t get out of the gate strong may not survive.

Choose one of the following retailers: Hair Cuttery; Hand and Stone Massage; Modell’s; Caesars casino; or Outback Steakhouse.

Describe the best way your retailer choice can use the four promotional components (sales promotion, publicity, social media and personal selling) to be successful when the lockdown is over.

In: Operations Management

Who within an organization should initiate the first kick-off of an idea for expansion or improving...

Who within an organization should initiate the first kick-off of an idea for expansion or improving of assets? And why? Discuss.

In: Operations Management

this question has been answered incorrectly several times can someone answer it correctly and show me...

this question has been answered incorrectly several times can someone answer it correctly and show me some examples of a run

Design and implement a class named Person and its two subclasses named Student and Employee.

Make Faculty and Staff subclasses of Employee.

A person has a name,address, phone number, and email address.

A student has a class status (year 1,year 2,year 3,or year 4).

An employee has an office, salary, and date hired.

Use the Date class from JavaAPI 8 to create an object for date hired.

A faculty member has office hours and a rank.

A staff member has a title.

Override the toString method in each class to display the class name and the person’s name.Design and implement all 5classes.

Write a test program that creates a Person,Student,Employee,Faculty, and Staff, and iinvokes their toString()methods

In: Computer Science

Jollibee foods corporation, a Philippine fast-food company, has achieved market dominance in three segments in its...

Jollibee foods corporation, a Philippine fast-food company, has achieved market dominance in three segments in its home country – burgers and chicken, pizzas, and Chinese food - beating such well-known international competitors as McDonald's and Pizza Hut. What is the key to its domestic success, and what are the lessons for its international ventures? JFC operates Jollibee, the Philippines ' largest and most successful homegrown fast-food chain. By targeting the niche Filipino market, Jollibee has beaten global players, including fast-food giant McDonalds, in the Philippine fast-good scene with its own unique menu and excellent service, Jollibee commands a 58 percent share of the quick-service restaurants market in the Philippines and some 70 percent of the burger based meals markets. To cater to the ever-changing needs of Filipinos, JFC has acquired a portfolio of complementary fast-good concepts, Greenwich Pizza, Chowking, and Delifrance (a French franchise). The company has been honored many times, being recognized for its entrepreneurship, as the number one food company in Asia as the best-managed company in the Philippines, and as Asia’s most admired company. It has also been consistently ranked among Asia’s best employers. To secure its leadership position, JFC intends to focus its efforts on increasing its presence in both local and international markets. However, it has not been particularly successful in establishing Jollibee and Chowking brands overseas. In 2004, it purchased the Yonghe King chain of Chinese fast-food restaurants in China and has high hopes for the future of this brand in the People’s Republic


Evaluate the JFC’s performance overseas. To what extent can the company transfer its core
competency to its overseas operations? Justify your answer by giving explanations and
examples.
b. Should it modify its consumer-driven strategies to suit foreign markets, even if that
means Jollibee becomes much less Philippine in nature? Justify your answer by giving
explanations and examples
Evaluate JFC’s performance overseas. To what extent can the company transfer its core
competency to its overseas operations? Justify your answer by giving explanations and
examples.
b. Should it modify its consumer-driven strategies to suit foreign markets, even if that
means Jollibee becomes much less Philippine in nature? Justify your answer by giving
explanations and examples
QUESTIONS (30 MARKS – 10 MARKS EACH)
1. Evaluate Jollibee’s Food Corporation’s performance in the Philippines. What is its secret of success in terms of:
i. Marketing
ii. Operations
iii. Human Resource Management

2. Evaluate JFC’s performance overseas. To what extent can the company transfer its core competency to its overseas operations? Justify your answer by giving explanations and examples.

3. Should it modify its consumer-driven strategies to suit foreign markets, even if that means Jollibee becomes much less Philippine in nature? Justify your answer by giving explanations and examples

In: Operations Management

Consider groups like Alcoholics Anonymous. Do such groups provide adequate solutions to people’s alcohol- or drug-related...

Consider groups like Alcoholics Anonymous. Do such groups provide adequate solutions to people’s alcohol- or drug-related problems? Why or why not? Use scholarly resources to support your explanation.

In: Psychology

How do the three methods of depreciation (include straight line method, units of production and double...

  • How do the three methods of depreciation (include straight line method, units of production and double declining balance method.) affect the income statement and the balance sheet?

In: Accounting

Sarah is buying a home. Her loan will be $100,000. She will make annual payments for...

Sarah is buying a home. Her loan will be $100,000. She will make annual payments for the next 30 years to retire this loan. The interest rate on the loan is 4 %.

A. How much will her annual payments be?

B. How much interest will she pay over the life of the loan?

C. How much of her first payment will be applied to principal?

D. How much will she still owe on the loan after 10 years?

In: Finance

Carlos and Shannon are sledding down a snow-covered slope that is angled at 12.0° below the...

Carlos and Shannon are sledding down a snow-covered slope that is angled at 12.0° below the horizontal. When sliding on snow, Carlos’s sled has a coefficient of friction μk = 0.100; Shannon has a “supersled” with μk = 0.0100. Carlos takes off down the slope starting from rest. When Carlos is 4.00 m from the starting point, Shannon starts down the slope from rest.

How far have they traveled when Shannon catches up to Carlos?

How fast is Shannon moving with respect to Carlos as she passes by?

In: Physics

Can anyone fix this code? The code isn't rounding the answer to the nearest whole number...

Can anyone fix this code? The code isn't rounding the answer to the nearest whole number like 2.345 should be 2 and 2.546 should be 3 but the round() function isn't working as expected. The round() function is rounding 2.546 to 2 which is incorrect since 4 and below should be rounded to 2 and 5 and above should be rounded to 3.

Here is the code:

#importing xlwt library to write into xls
import xlwt
from xlwt import Workbook

#create a workbook
wb = Workbook()
#create a sheet
sheet = wb.add_sheet('Sheet')

#percentages list
percentages = [23.6, 38.2, 50, 61.8, 78.6, 113, 123.6, 138.2, 161.8]
#add first row
for i in range(len(percentages)):
   sheet.write(0,i+1,str(percentages[i])+'%')

#user input
n = int(input('Enter number of elements: '))
#second row starts from index 1
row=1
print('Enter numbers: ')
for i in range(n):
    #User input
   val = float(input())
   #Add entered value to first column of the row
   sheet.write(row,0,str(val))
   #calculate each percentage
   for j in range(len(percentages)):
       result = (percentages[j]/100)*val
       #write result to sheet by rounding upto 3 decimal points
       sheet.write(row,j+1,str(round(result,3)))
   #increment the row by 1
   row+=1
#save Workbook as xls`
wb.save('percentages.xls')

Thank you so much for anyone who helped!

In: Computer Science

International Accounting What are the market transaction methods? Describe what is done in each of the...

International Accounting

What are the market transaction methods? Describe what is done in each of the market transaction methods.

what is the single rate / current rate translation methods? What is the temporal method? Describe what is done in each of the translations.

In: Accounting

How are teams used and evaluated at HOME DEPOT firm?

  1. How are teams used and evaluated at HOME DEPOT firm?

In: Operations Management

Identify and explain two ways that human resources professionals can support managers. Identify and explain two...

Identify and explain two ways that human resources professionals can support managers. Identify and explain two ways that controllers can support managers. Why is it important for managers to work collaboratively with controllers, human resource professionals and other internal stakeholders and leaders within the company?

In: Operations Management

Python Programming 4th edition: Write a program that asks the user for the number of hours...

Python Programming 4th edition: Write a program that asks the user for the number of hours (float) and the pay rate (float) for employee pay role sheet. The program should display the gross pay with overtime if any and without overtime. Hints: Given base_hr as 40 and ovt_multiplier as1.5, calculate the gross pay with and Without overtime. The output should look like as follows: Enter the number of hours worked: Enter the hourly pay rate: The gross pay is $XXX.XX

In: Computer Science

A director at an assisted living facility wants to offer a range of programs that support...

A director at an assisted living facility wants to offer a range of programs that support aging residents' cognitive functioning. What activities and interventions would you recommend, and why in 200 words.

In: Nursing