Engineering
Engineering, 14.03.2020 00:27, zacksoccer6937

A soft drink company recently surveyed 12,467 of its customers and found that approximately 14 percent of those surveyed purchase one or more energy drinks per week. Of those customers who purchase energy drinks, approximately 64 percent of them prefer citrus-flavored energy drinks. Write a Java program that displays the following:
*The approximate number of customers in the survey who purchase one or more energy drinks per week.
*The approximate number of customers in the survey who prefer citrus-flavored energy drinks.

This is what I have so far and it runs with no errors but my numbers being displayed at the end are not mathematically correct or look like they're in the right decimal format...Can't figure out what exactly needs to be changed.. Also what would be another datatype I could use for customers, as I realize they're not going to be a half.



public class Ex2_15 {
private double customers;
private double thoseThatPurch;
private double preferCitrus;
private double nopeople1;
private double nopeople2;

public Ex2_15()
{
customers = 12467;
thoseThatPurch = 14;
preferCitrus = 64;
}

public Ex2_15(double customers, double thoseThatPurch, double preferCitrus) {
this. customers = customers;
this. thoseThatPurch = thoseThatPurch;
this. preferCitrus = preferCitrus;
}

public void printOutput()
{
nopeople1 = customers * thoseThatPurch;
nopeople2 = nopeople1 * preferCitrus;

System. out. println("");
System. out. println("ENERGY DRINK CONSUMPTION");
System. out. println("");
System. out. println("Number of people surveyed: " + customers);
System. out. println("Number who purchase one or more energy drinks: " + nopeople1);
System. out. println("Number who prefer citrus flavored energy drinks: " + nopeople2);
System. out. println();
}

public static void main(String args[]) {
Ex2_15 edc1 = new Ex2_15();
Ex2_15 edc2 = new Ex2_15(12467.0,14.0,64.0);
edc1.printOutput();
edc2.printOutput();
}
}



END RESULT :


ENERGY DRINK CONSUMPTION

Number of people surveyed: 12467.0
Number who purchase one or more energy drinks: 174538.0
Number who prefer citrus flavored energy drinks: 1.1170432E7


ENERGY DRINK CONSUMPTION

Number of people surveyed: 12467.0
Number who purchase one or more energy drinks: 174538.0
Number who prefer citrus flavored energy drinks: 1.1170432E7

answer
Answers: 3

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 15:10, theamandawhite
Ahouse has the following electrical appliance usage (1) single 40w lamp used for 4 hours per day (2) single 60w fan used for 12 hours per day (3) single 200w refrigerator that runs 24 hours per day with compressor run 12 hours and off 12 hours find the solar power inverter size in watt with correction factor of 1.25.
Answers: 1
image
Engineering, 03.07.2019 19:30, 10040813
When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested? a. parallel b. control c. series d. line
Answers: 3
image
Engineering, 04.07.2019 18:10, meganwintergirl
Afour cylinder four-stroke in-line engine has a stroke of 160mm, connecting rod length of 150mm, a reciprocating mass of 3kg and its firing order is 1-3-4-2. the spacing between cylinders is 100mm. i. show that the engine is in balance with regard to the primary inertia forces and primary 3. a and secondary inertia couples. li determine the out of balance secondary inertia force ii. propose ways of balancing this out of balance force and discuss the challenges that will arise
Answers: 3
image
Engineering, 04.07.2019 18:10, alyssabailey7545
Give heat transfer applications for the following, (i) gas turbines (propulsion) ) gas turbines (power generation). (iii) steam turbines. (iv) combined heat and power (chp). (v) automotive engines
Answers: 1
Do you know the correct answer?
A soft drink company recently surveyed 12,467 of its customers and found that approximately 14 perce...

Questions in other subjects:

Konu
Mathematics, 28.04.2021 03:30
Konu
Mathematics, 28.04.2021 03:30