Solved

Beginning Pascal

Posted on 2000-02-21
2
192 Views
Last Modified: 2010-04-04
My assignment is to write a program that does the following:
Ask the user how many bills they are entering for calculation?
Have the user enter as many as 8 bills (the amount of each bill)
then add all the bills to get a total then get the average.
I understand how to get the total and average.
I also can get the user to enter how many bills they want to enter.
this is what I have so far --
begin

      writeln('How many bills will you be entering today?');
      readln(billnum);
      if billnum  <9 then
      else writeln('The system can calculate as many as 8 bills at a time.  Please enter 8 or less bills');
         readln;

end.

Can anyone help with creating a loop that will allow the user to enter the amounts of each bill???

Thanks a million !!!
0
Comment
Question by:jennyg
2 Comments
 
LVL 1

Accepted Solution

by:
nrico earned 100 total points
Comment Utility
Okay, this isn't too hard. (But technically, I have to mention the EE is NOT for homework assignments...)
____________________________________

Uses SysUtils;

Var
  Counter,Total:Integer;
  Input:String;

Begin
{ ... Your code goes here ... }
  Total:=0;
  For Counter:=1 To Billnum Do
  Begin
    Write('Please enter bill #',Counter,':');
    ReadLn(Input);
    Total:=Total+StrToInt(Input);
  End;
  WriteLn('Total is ',Total);
  WriteLn('Average is ',Total / Billnum);
End;

Actually, you can read the input directly as an integer (Given you use integers for your bills, if you want to use floating point numbers you have to use "Real"s), then you don't have to use StrToInt();

Success!
0
 

Author Comment

by:jennyg
Comment Utility
Thanks nrico,
This information was very helpful.  In the past I have used EE to help me with my home work assignments.  I really don't expect people to give me the answers, but people have pointed me to web sites that have the information I am looking for and that has been very helpful.
Thanks again !!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now