1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
asambeis [7]
3 years ago
14

Create a program that compares the unit prices for two sizes of laundry detergent sold at a grocery store.

Computers and Technology
1 answer:
astraxan [27]3 years ago
4 0

Complete Question:

Create a program that compares the unit prices for two sizes of laundry detergent sold at a grocery store. Console Price Comparison Price of 64 oz size: 5.99 Price of 32 oz size: 3.50 Price per oz (64 oz): 0.09 Price per oz (32 oz): 0.11

Using Python

Answer:

<em>This program does not make use of comments (See explanation section)</em>

price64 = float(input("Price of 64 oz size: "))

price32 = float(input("Price of 32 oz size: "))

unit64 = price64/64

unit32 = price32/32

print("Unit price of 64 oz size: ", round(unit64,2))

print("Unit price of 32 oz size: ", round(unit32,2))

if unit64>unit32:

     print("Unit price of 64 oz is greater" )

else:

     print("Unit price of 32 oz is greater" )

Explanation:

This line prompts the user for the price of 64 oz size

price64 = float(input("Price of 64 oz size: "))

This line prompts the user for the price of 32 oz size

price32 = float(input("Price of 32 oz size: "))

This line calculates the unit price of 64 oz size

unit64 = price64/64

This line calculates the unit price of 32 oz size

unit32 = price32/32

This next two lines print the unit prices of both sizes

print("Unit price of 64 oz size: ", round(unit64,2))

print("Unit price of 32 oz size: ", round(unit32,2))

The next line compares the unit prices of both sizes

if unit64>unit32:

This line is executed if the unit price of 64 oz is greater than 32 oz

     print("Unit price of 64 oz is greater" )

else:

This line is executed, if otherwise

     print("Unit price of 32 oz is greater" )

You might be interested in
What is the purpose of filters in a data base
Liono4ka [1.6K]
Filters let you filter out certain things or search for them. For example if i'm looking through a database with all the students grades. I could filter out everything that doesnt math a students name. This would only show results for what I searched for.
8 0
4 years ago
Create a class, using separate files, named DynamicGrades. (2 points) This class has three data members: an int that represents
Alex

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

//DynamicGrades.h

class DynamicGrades

{

public:

DynamicGrades(int size);

~DynamicGrades();

void mutate(int studentId, int index, int grade);

int getGrade(int studentId, int index);

private:

int m_studentId;

int m_noofGrades;

int* m_dynamicArr;

};

//DynamicGrades.cpp

#include "DynamicGrades.h"

DynamicGrades::DynamicGrades(int size)

{

m_noofGrades = size;

m_dynamicArr = new int[m_noofGrades] {0};

}

DynamicGrades::~DynamicGrades()

{

if(nullptr != m_dynamicArr)

delete[] m_dynamicArr;

}

void DynamicGrades::mutate(int studentId, int index, int grade)

{

m_studentId = studentId;

if (index < m_noofGrades)

m_dynamicArr[index] = grade;

}

int DynamicGrades::getGrade(int studentId, int index)

{

if (index >= m_noofGrades)

return -1;

return m_dynamicArr[index];

}

//Main.cpp

#include "DynamicGrades.h"

int main()

{

DynamicGrades* grade = new DynamicGrades(5);

DynamicGrades grade2(10);

for (int i = 0;i < 5;++i)

{

grade->mutate(2, i, i + 1);

}

for (int i = 0; i < 10; i++)

{

grade2.mutate(3, i, i + 1);

}

cout << "Grades are " << endl;

for (int i = 0;i < 5;++i)

{

cout << grade->getGrade(2, i) <<" ";

}

cout << endl;

for (int i = 0; i < 10; i++)

{

cout << grade2.getGrade(3, i) << " ";

}

}

3 0
4 years ago
Write a program that uses nested loop or for statements to display Pattern A below, followed by an empty line and then another s
JulsSmile [24]

Answer:

public class Pyramid {

   public static void main(String[] args) {

             int h = 7;

       System.out.println("Pattern A");

               for(int i = 1; i <= h; ++i)

               {

                   for(int j = 1; j <= i; ++j) {

                       System.out.print("+");

                   }

                   System.out.println();

               }

       System.out.println();

       System.out.println("Pattern B");

               for (int i = 1; i<=h; ++i)

               {

                 for(int j = h; j >=i; --j){

                     System.out.print("+");

                 }

                   System.out.println();

               }

           }

       }

Explanation:

  • The trick in this code is using a nested for loop
  • The outer for loop runs from i = 0 to the heigth of the triangle (in this case 7)
  • The inner for loop which prints the (+) sign runs from j = 0 to j<=i
  • It prints the + using the print() function and not println()
  • In the pattern B the loop is reversed to start from  i = height
8 0
3 years ago
9. The voltage of a replacement capacitor must
nasty-shy [4]

Answer:

B

Explanation:

It is the capacity (in Farad) of the capacitor that determines its behaviour in the circiut. The voltage is merely a qualification of what it can handle. Higher is "better".

6 0
3 years ago
Write a program that finds the largest in a series of numbers entered by the user.The program must prompt the user to enter numb
Kobotan [32]

Answer:

Here is c program:

#include<stdio.h>

#include<conio.h>

void main()

{

//Variable declaration

//array to hold 6 values you can change this as needed

float nums[6];

//integer i is for loop variable

int i;

//to hold maximum value

float max=0.0;

//clear screen

clrscr();

//iterate 6 times you can change as per your need

for(i=0;i<6;i++)

{

printf("Enter a number:");

scanf("%f",&nums[i]);

//check if entered value is greater than previous value

//if it is greater then assign it

if(nums[i]>max)

max = nums[i];

}

//print the value

printf("The largest number entered was %f",max);

getch();

}

Explanation:

4 0
4 years ago
Other questions:
  • Carolyn owns a small business that designs air conditioning units for large buildings. A construction company that's building an
    13·1 answer
  • Remember that the function "main" takes optional parameters, these being common:
    10·1 answer
  • What was the han dynasty and the roman empire known for?
    5·1 answer
  • What is a data mining??
    5·1 answer
  • Radiation requires a heated liquid to transfer energy. Please select the best answer from the choices provided T F
    10·2 answers
  • Enhancing and optimizing customer retention and loyalty is a major business strategy.
    15·1 answer
  • A relational database is different from a simple database because it has more than one _____.
    13·1 answer
  • For current events, what type of sources would we use to learn about them?
    14·1 answer
  • 9. "मेरे तो गिरधर गोपाल, दूसरो ना कोई
    5·1 answer
  • Will this website ever get itself together to stop people from sending links?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!