The owner of a candle shop has asked for your help. The shop sells three types of candles as shown below:


Type Price Burn Time (hours)
1 $2.50 5
2 $3.75 7
3 $5.99 12

The owner wants you to write a program to perform certain calculations when customers buy different numbers of the candles.

Required:
a. Develop an algorithm to satisfy the following requirements:

Prompt the user to enter the number of candles of each type the customer wants to buy. Since you can’t buy a fraction of a candle, the input for each type of candle must be an integer. (You may assume that only integer values between 0 and 10 will be entered when this program is tested.)
Calculate the total price of all the candles bought using the information in the table above. For example, two Type 1 candles and one Type 2 candle would have a total price of $8.75.
Calculate the total burn time of all the candles if they were burned consecutively (i.e., one after the other). For example, one Type 1 and one Type 3 candles would burn for 17 hours.
Calculate the cost-per-minute for that purchase.
Output some kind of meaningful display that includes the number of candles of each type bought, the total price, the total burn time, and the cost-per-minute. You can be as creative as you want with this!
Write the pseudocode for the algorithm and store it in a file (file format can be text, pdf or doc) with the name CandleShopSteps.

b. Write the code (20 points)

Once you've written your algorithm it is time to turn it into a Java program. that can be executed (run). Here are some things to keep in mind:

the class should be name CastleShop.
the program will need to import the Scanner class from the Java util package.
the class should have a main method that will include the logic for the algorithm you developed in Part A. You may choose to add additional methods that are called in the main method.

Answers

Answer 1

Answer:

import java.util.Scanner;

public class Main {

 public static void main(String[] args) {

   double total = 0;

   double fPrice, sPrice, tPrice;

   int firstN = 0, secdN = 0, thirdN = 0, fTime, sTime, tTime;

   int totalT = 0;

   isEnd = "n";

   for (;;){

       if (isEnd == "y"){

           break;

       }

       Scanner in = new Scanner(System.in);

       int option = in.nextInt();

       switch (option){

         case 1:

             fPrice = 2.50;

             fTime = 5;

             System.out.print("Enter number of items: ");

             firstN += in.nextInt();

             totalT += fTime * firstN;

             total += fPrice * firstN;

             break,

         case 2:

             sPrice = 3.75;

             sTime = 7;

             System.out.print("Enter number of items: ");

             secdN += in.nextInt();

             totalT += sTime * secdN;

             total += sPrice * secdN;

             break,

         case 3:

             tPrice = 5.99;

             tTime = 12;

             System.out.print("Enter number of items: ");

             thirdN += in.nextInt();

             totalT += tTime * thirdN ;

             total += tPrice * thirdN;

             break,

        default:

             System.out.println("Looking forward to the Weekend");

       }

       System.out.print("Do you want to end the order? y/n: ");

       isEnd = in.nextLine();

   }

   System.out.println("Number of Type 1 candles bought : "+firstN);

   System.out.println("Number of Type 2 candles bought : "+secdN);

   System.out.println("Number of Type 3 candles bought : "+thirdN);

   System.out.println("Total cost is : "+total);

   System.out.println("Total burn time is : "+totalT);

   double costPerBurn = (totatT * 60) / total;

   System.out.println("Cost per minute : "+ costPerBurn);

 }

}

Explanation:

The Java program creates a continuous for-loop statement that gets the candle type, price and amount ordered from a switch and accumulates the total cost and burn time of the candles bought and the cost per minute burn of the candles consecutively.


Related Questions

Write a program that asks the user to enter a series of single digit numbers with nothing separating them. Read the input as a C-string or a string object. The program should display the sum of all the single-digit numbers in the string. For example, if the user enters 2514, the program should display 12, which is the sum of 2, 5, 1, and 4. The program should also display the highest and lowest digits in the string.

Answers

Answer:

#include <stdio.h>

#include <string.h>

int main(){

   char number[100];

   printf("Number: ");

   scanf("%s", number);

   int sum = 0;

   for(int i =0;i<strlen(number);i++){

       sum+= number[i] - '0';

   }

           printf("Sum: %d",sum);

   return 0;

}

Explanation:

This declares a c string of 100 characters

   char number[100];

This prompts user for input

   printf("Number: ");

This gets user input

   scanf("%s", number);

This initializes sum to 0

   int sum = 0;

This iterates through the input string

   for(int i =0;i<strlen(number);i++){

This adds individual digits

       sum+= number[i] - '0';

   }

This prints the calculated sum

           printf("Sum: %d",sum);

   return 0;

The program that ask the user to enter a series of single digit number and display the sum of all the single digit number, highest number and lowest number is as follows:

x = input("input the series of number: ")

y = []

for i in x:

  y += i

integer_map = list(map(int, y))

print(sum(integer_map))

print(max(integer_map))

print(min(integer_map))

The code is written in python.

Code explanation:The first line of code ask the user for the series of numbers. The user input is stored in the variable "x"The y variable is an empty arraywe use the for loop to loop through the users series of number. Then add the looped items to the empty array.Then we map the string of list to an integersFinally, we print the sum , maximum and minimum number of the list.

learn more on python program: https://brainly.com/question/16025032?referrer=searchResults

Cell address A4 in a formula means it is a _________Mixed cell reference

A. Relative cell reference

B. Mixed cell reference

C. Absolute cell reference

D. All of the above

Answers

Answer:

A. Relative cell reference.

Explanation:

A relative cell reference is like a pointer to a cell or range of cell in Excel. In Excel all cell references, by default, are relative cell references.

In the given instance, the cell address A4 in a formula means it is a relative cell reference. If there would have been a $ sign before A4, then it will be an absolute cell reference. But since, it is without dollar sign, it is a relative cell reference.

Therefore, option A is correct.

How much water does the Hill family use per week?

Answers

Answer:

The Hill family uses69 pints

Explanation:

bc why not

Consumers who pay more than the minimum payment on credit cards...
are crazy, why pay more than you need to?
O pay less interest in the long run.
O see their credit scores decrease.
are able to buy more things.

Answers

Pay less interest in the long run

Justify the importance of Computer and internet security system.​

Answers

It helps keep your information protected. This reduces the risk of falling victim of data theft and sabatoge. Network security helps protect your computer from harmful spyware as well

Which view displays the records in columns and rows like excel worksheet​

Answers

Answer:

Datasheet View

Explanation:

Chapter 1

A B

Database Template A preformatted database designed for a specific purpose.

Datasheet View The Access view that displays data organized in columns and rows similar to an Excel worksheet.

explain the relevancy of computers in today's global society​

Answers

Computers in today’s society connect different backgrounds of people and cultures with access to extensive information throughout the internet. With this, the relevancy of a computer is extremely common due to the ability and access to information the device holds.

A network manager is interested in a device that watches for threats on a network but does not act on its own, and also does not put a strain on client systems. Which of the following would BEST meet these requirements?

a. HIDS
b. NIDS
c. NIPS
d. HIPS

Answers

Answer:

Option b (NIDS) is the correct choice.

Explanation:

NIDS helps to detect suspicious internet activity. Throughout order to determine all congestion, along with all network packets, unfaithful user information was indeed probably recommended. They were indeed technologies that are already constructively divided up in less than service providers that ineffectively investigate traffic through the systems on something they have been located.

All those other available options aren't closely linked to the scenario in question. Therefore this obvious response is the correct one.

How would you open the web browser in Linux and still have access to the Linux terminal?

Answers

Answer:

Use the command "sensible-browser" I could be wrong I have not used linux in some time.

Explanation:

(Numerical Data Representation) How many bits per word are required to represent the following positive decimal integers: a.0 through 100b.0 through 255c.0 through 256d.0 through 10,000,000

Answers

Answer:

a. 7 bits

b. 8 bits

c. 9 bits

d. 24 bits

Explanation:

Required

Number of bits per word

The formula to get the number of bits per word is:

[tex]2^n = N[/tex]

Where

n = bits

N = numbers

Solving (a) 0 to 100

There are 101 digits between 0 and 100 (inclusive)

So:

[tex]N = 101[/tex]

Substitute 101 for N in [tex]2^n = N[/tex]

[tex]2^n = 101[/tex]

101 can not be expressed as an exponent of 2.

So, we substitute 101 for the closest number greater than 101 that can be expressed as an exponent of 2.

So:

[tex]2^n = 128[/tex]

Express 128 as an exponent of 2

[tex]2^n = 2^7[/tex]

Apply law of indices

[tex]n = 7[/tex]

Hence, 7 bits are required

Solving (b): 0 through 255

There are 256 digits between 0 and 255 (inclusive)

So:

[tex]N = 256[/tex]

Substitute 256 for N in [tex]2^n = N[/tex]

[tex]2^n = 256[/tex]

Express 256 as an exponent of 2

[tex]2^n = 2^8[/tex]

Apply law of indices

[tex]n = 8[/tex]

Hence, 8 bits are required

Solving (c): 0 through 256

There are 257 digits between 0 and 256 (inclusive)

So:

[tex]N = 257[/tex]

Substitute 257 for N in [tex]2^n = N[/tex]

[tex]2^n = 257[/tex]

257 can not be expressed as an exponent of 2.

So, we substitute 257 for the closest number greater than 101 that can be expressed as an exponent of 2.

So:

[tex]2^n = 512[/tex]

Express 512 as an exponent of 2

[tex]2^n = 2^9[/tex]

Apply law of indices

[tex]n = 9[/tex]

Hence, 9 bits are required

Solving (d): 0 through 10000000

There are 10000001 digits between 0 and 10000000 (inclusive)

So:

[tex]N = 10000000[/tex]

Substitute 10000000 for N in [tex]2^n = N[/tex]

[tex]2^n = 10000000[/tex]

10000000 can not be expressed as an exponent of 2.

So, we substitute 10000000 for the closest number greater than 101 that can be expressed as an exponent of 2.

So:

[tex]2^n = 16777216[/tex]

Express 16777216  as an exponent of 2

[tex]2^n = 2^{24[/tex]

Apply law of indices

[tex]n = 24[/tex]

Hence, 24 bits are required

Consider the classes Food, Cheese, and Velveeta where Cheese is a subclass of Food and Velveeta is a subclass of Cheese. State which of the following lines of code are legal.

Cheese c =new Food( );
Velveeta v =new Food( );
Cheese c =new Velveeta( );
Food f =new Velveeta( );
Food f =new Cheese( );

Answers

Answer:

Cheese c =new Velveeta( );

Food f =new Velveeta( );

Food f =new Cheese( );

Explanation:

The super-class is the parent class from which features and attributes are inherited from while the subclass or the child class is the class inheriting from the super or parent class.

In Java, the object instance of a class is created with the syntax;

class_name instance_name = new class_name();

Food is the super or parent class of Cheese (which makes Cheese its subclass) and Cheese is the parent class of Velveeta. The extends keyword is used to denote inheritance.

g Write a program that allows a user to input any text in your program. Using the tools that we have discussed, your program should output how many unique words were in the input and then output how many words were unique.

Answers

Answer:

Explanation:

The following function/program is written in Java. It asks the user for a sentence as an input and then splits that sentence into an array of words. Then it creates an arrayList for all of the unique words, comparing each word in the sentence with all of those in the ArrayList. If a word is found in the ArrayList it cancels the loop and moves on the next word in the sentence. Finally, it counts all of the unique words in the ArrayList and prints that total to the screen.

public static void uniqueWords() {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter a sentence:");

       String sentence = in.nextLine();

       String words[] = sentence.split(" ");

       ArrayList<String> uniqueWords = new ArrayList<>();

       for (int x = 0; x < words.length; x++) {

           boolean exists = false;

           for (int i = 0; i < uniqueWords.size(); i++) {

               if (words[x].equals(uniqueWords.get(i))) {

                   exists = true;

                   break;

               }

           }

           if (exists == false) {

               uniqueWords.add(words[x]);

           }

       }

       System.out.println(uniqueWords.size());

   }

An instruction for the computer. Many commands put together to
make up algorithms and computer programs.

1. Repeat
2. Command
3. Bug

Answers

Answer:

i think its command but not sure

Question 5
2 pts
The type of control structure that
causes a branch forward at some
point, causing a portion of the
program to be skipped, is:
a selection structure.
O a seguential structure
a repetition structure
a loop structure

Answers

Answer:

Selection structure.

Explanation:

In a decision structure (selection structure), there is a branch forward at some point, which causes a portion of the program to be skipped. A loop structure (repetition structure) contains a branch to a previous statement in the program module, which results in a block of statements that can be executed many times.

Match the IP Protections Patent, Copyright and Trademark into the following cases:

a. books, poems
b. music, movies, paintings
c. company logo
d. software
e. combinations of materials to make drugs

Answers

Answer:

A) copyright

B) copyright

C)Trade mark

D) copyright

E)Patent

Explanation:

Patent can be regarded as a form of intellectual property which helps the owner of an invention to others to sell or use the invention for some period of time. Example of this is a patent that protect microwave oven.

trademark is form of intellectual property, this could be inform of symbols, words that differentiate the product of a party from another. Example of this is a bite of apple that represents apple products.

Copyright can be regarded as a legal right given to those that owns a intellectual property which gives him/her right to copy and exclude others from reaping from where they did not sow. The owner get exclusive right to reproduce the copy.

Below is the match of the intellectual property with the examples.

a. books, poems<> Copyright

b. music, movies, paintings<> Copyright

c. company logo<> Trademark

d. software<>Copyright

e. combinations of materials to make drugs<> patent

What are two main components to using functions (there are three from you to choose from)? What do each do? Why are they important?

Answers

Answer:

function is a self-contained program segment that carries out some specific, well-defined task. Every C program consists of one or more functions. One of these functions must be called main. Execution of the program always begins by carrying out the instructions contained in main. Note that if a program contains multiple functions then their definitions may appear in any order. The same function can be accessed from several different places within a program. Once the function has carried out its intended action, control is returned to the point from which the function was accessed. Generally speaking, a function processes information passed to it from the calling portion of the program, and returns a single value. Some functions, however, accept information but do not return anything.

A function definition has two principal components: the first line (including the argument declarations), and the so-called body of the function.

The first line of a function takes the general form data-type  name(type 1  arg 1,  type 2  arg 2,  ...,  type n  arg n)

where data-type represents the data type of the item that is returned by the function, name represents the name of the function, and type 1, type 2, ..., type n represent the data types of the arguments arg 1, arg 2, ..., arg n. The allowable data types for a function are:

int       for a function which returns an integer value

double    for a function which returns an floating-point value

void      for a function which does not return any value

The allowable data types for a function's arguments are int and double. Note that the identifiers used to reference the arguments of a function are local, in the sense that they are not recognized outside of the function. Thus, the argument names in a function definition need not be the same as those used in the segments of the program from which the function was called. However, the corresponding data types of the arguments must always match.

The body of a function is a compound statement that defines the action to be taken by the function. Like a regular compound statement, the body can contain expression statements, control statements, other compound statements, etc. The body can even access other functions. In fact, it can even access itself--this process is known as recursion. In addition, however, the body must include one or more return statements in order to return a value to the calling portion of the program.

A return statement causes the program logic to return to the point in the program from which the function was accessed. The general form of a return statement is:

return  expression;

This statement causes the value of expression to be returned to the calling part of the program. Of course, the data type of expression should match the declared data type of the function. For a void function, which does not return any value, the appropriate return statement is simply:

return;

A maximum of one expression can be included in a return statement. Thus, a function can return a maximum of one value to the calling part of the program. However, a function definition can include multiple return statements, each containing a different expression, which are conditionally executed, depending on the program logic.

Note that, by convention, the main function is of type int and returns the integer value 0 to the operating system, indicating the error-free termination of the program. In its simplest form, the main function possesses no arguments. The library function call exit(1), employed in previous example programs, causes the execution of a program to abort, returning the integer value 1 to the operating system, which (by convention) indicates that the program terminated with an error status.

The program segment listed below shows how the previous program factorial.c can be converted into a function factorial(n) which returns the factorial (in the form of a floating-point number) of the non-negative integer n:

double factorial(int n)

{

 /*

    Function to evaluate factorial (in floating-point form)

    of non-negative integer n.

 */

 int count;

 double fact = 1.;

 /* Abort if n is negative integer */

 if (n < 0)

  {

   printf("\nError: factorial of negative integer not defined\n");

   exit(1);

  }

 /* Calculate factorial */

 for (count = n; count > 0; --count) fact *= (double) count;

 /* Return value of factorial */

 return fact;      

}

Explanation:

How will Excel summarize the data to create PivotTables? summarize by row but not by column summarize by column but not by row summarize by individual cells summarize by row and by column

Answers

Answer:

D. summarize by row and by column

Answer:

D.

Explanation:

QUESTION 1

Which part of an Ethernet Frame uses a pad to increase the frame field to at least 64 bytes?

Answers

Answer:

Data field.

Explanation:

In Computer Networking, data encapsulation can be defined as the process of adding a header to a data unit received by a lower layer protocol from a higher layer protocol during data transmission. This ultimately implies that, the header (segment) of a higher layer protocol such as an application layer, is the data of a lower layer such as a transportation layer in the Transmission Control Protocol and Internet Protocol (TCP/IP).

Basically, an Ethernet Frame is one of the IEEE 802.3 data encapsulation standards.

An Ethernet Frame can be defined as the building blocks or bits contained in a single packet of data that is being transmitted over an Ethernet network or connection. When data are transmitted, a frame check sequence (FCS) containing a 4-bytes is used to detect or check for any error in a frame and to ensure no frame data was corrupted in the course of the transmission.

In the transmission control protocol (TCP), all frames that are being transmitted must have a minimum of 64-bytes in length and as such when small packets are encapsulated, some additional bits referred to as pad are typically used to increase the frame size to at least 64-bytes, which is the minimum size.

Hence, a data field is the part of an Ethernet Frame that uses a pad to increase the frame field to at least 64 bytes.

You are a network technician for a small network. Your ITAdmin workstation just stopped communicating with all other computers in the network. You need to diagnose and fix the problem. The following IP addresses are used in this lab:

Location Computer Name IP Address
Networking Closet CorpServer 172.25.10.10
Office 1 Office 1 172.25.10.60
Office 2 Office 2 172.25.10.61
Support Office Support 172.25.10.62
IT Administration ITAdmin 172.25.10.63
Executive Office Exec 172.25.10.64

Answers

Answer:

Ping the other workstations from the IT Admin workstation to confirm that connection has been lost, check the status of the network interface card in the workstation with command ifconfig in the terminal, then reset the connection using ifdown and ifup commands. If the problem is not resolved, check the cable connection.

Explanation:

Ping is an ICMP echo message sent by a network host to another to check for connectivity. If they are connected, the other workstation responds with an ICMP response message.

The ifconfig in Linux systems displays the network adapters and their individual IP configurations. If there is no connection even after the network is reset, then the cable connectors could be the problem.

True or False: The major advantage of Arrays over ArrayLists in Java is the fact that while ArrayLists are fixed in size, an Array can increase or decrease in size as needed.

Answers

Answer:

False

Explanation:

It's the other way round actually. Arraylists do not have fixed size and can increase or decrease in size as needed. On the other hand, Arrays are fixed from when they are declared; they have a particular size that number of elements cannot go beyond.

An arraylist in Java is a class that is part of a Java collection framework(java.util) that can have variable sizes and only store objects, not primitive data like strings or integers. An array is a data structure in Java and can store both primitive data and objects, while having a fixed size at declaration.

please tell fast plzzzzzz​

Answers

Answer:

(1001) =9

(45)= 101101

Other Questions
Explain a stress reduction technique and specifically, how the technique is used by you or someone you know PLEASE HELP ME ITS THE LAST QUESTION ASAPfill in the blanksPor qu no ___ los verbos? Sin verbos no puedes hablar. Write the following statement as a mathematical expression.Let x be a number.The quotient of two and a number, subtracted from seventeen Rewrite this passage so that it includes at least one compound, complex, or compound-complex sentence.You should not get up. You should not make dinner. You think you feel fine. You need to stay in bed. You are sick. You need to give your body a chance to get well. You will only get better with rest. 2. Solve (x 4)(x + 7). (2 points) O x = 4, X= 7 X = =4, x = -7 x = 4, X = -7 X = -4, X = 7 A math tutor makes $12 an hour for the first 40 hours worked What is the sum of 6501.6 list the criteria that describes BPD (borderline personality disorder?) please help me!!!! Which energy output objects work with the solar panels? What is the scale factor in the dilation? True or false?The fall of the Roman Empire around 500 AD or CE isconsidered the beginning of the Middle Ages. Cohlsen Corporation has a favorable materials quantity variance. Which department would likely be asked to explain the cause of this variance If a 0.8kg ball is thrown with a velocity of 5 m/s,what is its KE?(KE=1/2 x m x v2) Two triangular tiles each have two sides measuring four inches. Which is a true statement?A) Their corresponding angles are congruent.B) The triangles are congruent.C) The triangles may be congruent.D) The triangles cannot be congruent. Read this paragraph from the essay.I have now been in India for over two years and a half after my return from South Africa. Over one quarter of that time I have passed on the Indian trains travelling third class by choice. I have travelled up north as far as Lahore, down south up to Tranquebar, and from Karachi to Calcutta. Having resorted to third class travelling, among other reasons, for the purpose of studying the conditions under which this class of passengers travel, I have naturally made as critical observations as I could. I have fairly covered the majority of railway systems during this period. Now and then I have entered into correspondence with the management of the different railways about the defects that have come under my notice. But I think that the time has come when I should invite the press and the public to join in a crusade against a grievance which has too long remained unredressed, though much of it is capable of redress without great difficulty.How does the author's decision to use the word crusade to describe a protest movement affect the text?It makes the protest sound especially strong and committed.It adds an element of irony to the description of the protest.It implies that the protesters will not back down, no matter what.It suggests that there is a religious reason behind the protest. You can name a plane with 3 Collinear points True or False?? Whereas, on the twenty-second day of September, in the year of our Lord one thousand eight hundred and sixty-two, a proclamation was issued by the President of the United States, containing, among other things the following, to wit:That on the first day of January, in the year of our Lord one thousand eight hundred and sixty-three, all persons held as slaves within any State or designated part of a State, the people whereof shall then be in rebellion against the United States, shall be then, thenceforward, and forever free.Emancipation Proclamation,Abraham LincolnWhat does Lincoln proclaim in the Emancipation Proclamation?Enslaved people across the United States are to be freed.Enslaved people in states in rebellion against the United States are to be freed.States in rebellion against the United States are to be granted their freedom.Enslaved people in rebellion are to be granted their freedom. A county fair has different ticket prices for adults and children. The expression 6a + 5c represents the total cost in dollars of tickets for a adults and c children. The Patel family spends $38 on tickets. How many adult tickets and child tickets do they buy? Match the IP Protections Patent, Copyright and Trademark into the following cases: a. books, poems b. music, movies, paintings c. company logo d. software e. combinations of materials to make drugs