Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
  • Entry

    1
  • Comments

    6
  • Views

    3244

About this blog

It's awesome and interesting.

Entries in this blog

As part of the degree I'm aiming to get, I have to do programming courses for the credit, so I'd log some of the stuff I've worked on here. The first major assignment?

 

"You are selling jars of honey at a fruit stand. The cost of a jar is $5.40 per jar or 3 jars for $15.00. There is also a 10.0% tax added to the cost of the purchase. Write a C++ program that asks the user to input the number of jars of honey purchased and display to the monitor the cost of the jars, the tax, and the total amount due. The cost per jar, cost per 3 jars, and the tax should be constants. Remember for more than 3 jars, the customer will receive the 3 jar price for all multiples and single jar price for any remainder (use the / and % operators to determine this)."

 

Yeah, this had me stumped until someone told me to use a crapton of variables. Now I made something that works in the console in linux:

 


#include <iostream>
using namespace std;
int main()
{
  int jars, sets_3, sets_1;
  const double priceSingle = 5.40;
  const double priceTriple = 15.00;
  const double taxRate = 0.10; // These constants are used.
  double cost1, cost2, subTotal, subTax, totalCost; /* These are doubles for
                                                       decimal purposes */

  cout<<"Enter the amount of jars you're buying:"<<endl;
  cin>>jars; // You input the amt of jars needed here

  sets_3=(jars/3);
  sets_1=(jars%3);

  cost1=(sets_3*priceTriple);
  cost2=(sets_1*priceSingle);

  subTotal=(cost1+cost2);
  subTax=(subTotal*taxRate);
  totalCost=(subTotal+subTax); // These are calculations.

  cout<<"The subtotal cost of the jars is:"<<subTotal<<endl;
  cout<<"The tax on the jars is:"<<subTax<<endl;
  cout<<"The total cost on the jars is:"<<totalCost<<endl;

  return 0;
}

 

I think it's only gonna get more tricky from here on out. I had to tag a few comments in, so...

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.