Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
We can use variables to solve problems like those we might solve in a spreadsheet. Imagine that
you had a spreadsheet with an invoice for an office supply company.
Here’s a program to compute the total price for the invoice:
There are three variables per line, two lines, and one total.
5
There are three variables per line, two lines, and one total.
2
There are three variables per line, two lines, and one total.
We don’t really have to create new variables quantity2 and unitPrice2. We only use those to compute the total for the line, and then we could reuse those variable names.
That would work, but giving names to numbers makes code easier to understand.
Write the code to calculate and print how many paperclips you can buy if each paperclip is $0.05 and you have $4.00 in your pocket. It should print 80.
Create variables to hold each value. Calculate numPaperclips as budget/costPerClip. Be sure to print the result.