Please see attachment.
Main Topics
Browse All TopicsCan you please tell me where I'm making my mistakes at.
declare -iGrade1
read -p Please enter your first grade: Grade1 Grade1
if [ $Grade1 -ge 90 -a $Grade1 -le 100]
then
read -p Enter Grades Grades
echo A
then
declare -iGrade2
read -p Please enter your first grade: Grade2 Grade2
if [ $Grade2 -ge 89 -a $Grade2 -le 80]
then
read -p Enter Grades Grades
echo B
then
declare -iGrade3
read -p Please enter your first grade: Grade3 Grade3
if [ $Grade3 -ge 79- a $Grade3 -le 70]
then
read -p Enter Grades Grades
echo C
then
declare -iGrade4
read -p Please enter your first grade: Grade4 Grade4
if [ $Grade4 -ge 65-a $Grade4 -le 69]
then
read -p Enter Grades Grades
echo D
then
declare -iGrade5
read -p Please enter your first grade: Grade5 Grade5
if [ $Grade5 -ge 0 -a $Grade5 -le 64]
then
read -p Enter Grades Grades
echo F
fi
then
if [[ GRADE1= A || GRADE2= B || GRADE3= C || GRADE4= D || GRADE5= F ]]
then ((Average=($Grade1 + $Grade2 + $Grade3)/3))
This question is in progress.
Our experts are working on an answer right now.
Sign up for immediate access to the solution once it becomes available.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
We can't give you a complete answer (that's not ee's job), but there were some important comments in the previous version of this question. To summarise and clarify:
Firstly, you should simply ask for the three grade numbers, one after the other - do no other work on them. Your code to ask for the grades is fine.
Then you calculate the average - your code looks good for this.
Then you print out the letter equivalent for the average numerical grade. You use "if" tests as above - each test compares $Average with 90 and 100, with 80 and 89 and so on. Make sure that you get the tests the right way round - for example, the test for B is "greater than or equal to 80, and less than or equal to 89". Then within each "if" test you simply print out the corresponding letter. Only one of the tests will match the Average value that you have, so only one of them will print out a grade letter.
As pointed out before, you must have a space after the "[" and before the "]" in tests. Also the case of the variables s important - GRADE1 and Grade1 are two different variables.
Sorry to hear we couldn't help. I would have responded if you had come back with more questions.
If you have to do this sort of thing again, try to do the script in chunks. For this one, first get the data entry section working:
declare -iGrade1
declare -iGrade2
declare -iGrade3
read -p "Please enter your first grade: " Grade1
read -p "Please enter your second grade: " Grade2
read -p "Please enter your third grade: " Grade3
echo Grades are $Grade1 $Grade2 $Grade3
Once that prints out the three values you enter, you can then add lines to the script to calculate the average (your "((Average=($Grade1 + $Grade2 + $Grade3)/3))" does that fine). Also add a line to print out the average ("echo Average is $Average")
Once *that* works, and it prints out the three values, then the average of the three values, then you can add the tests for the grade percentages (as you have done, if $Average is greater than or equal to 90 and less than or equal to 100, print an "A", and so on for B, C, D, E, all testing the value of $Average).
Once it all works, you can, if you want, remove the debug statements (the ones which print out the values and the average), though I would be inclined to leave them in - always useful to provide feedback to the user!
Business Accounts
Answer for Membership
by: woolmilkporcPosted on 2009-10-29 at 07:55:32ID: 25694346
Hi,
your code can't be read easily because of the blurred representation of special characters. Try to post it again, perhaps as an attachment.
The first thing I can see - always use spaces around the square brackets ( [ ... ] )!
Next, put a space between 'declare -i' and the variable name.
The last 'if ...' makes no sense at all - undefined variables, wrong type.
Waiting for your new post.
wmp