Error received

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Error received
# 1  
Old 04-14-2018
Question Error received

I have a program that i need to get done that gets the person's name and his grade then prints it in this order "name-grade-gradeletter" so i wrote this code:

Code:
#!/bin/bash
while :; do
read -p "Enter the person's name: " name
read -p "Enter the grade of the person: " grade

case $grade in
[50-59]) echo "$name $grade F";;
[60-69]) echo "$name $grade C";;
[70-79]) echo "$name $grade B";;
[80-100]) echo "$name $grade A";;
*) echo "Wrong input"

esac
done
echo "Goodbye"

So when you input the name and the grade, it just skips to the asterisk and outputs "Wrong input". Shouldn't it go through the values since the case is $grade and is using grade that is given by the person ?

Can someone tell me my mistake ?




P.S i tried changing the case to if command to see if it works but it shows me that no such file exists ?:

Code:
if [$grade >= 50||$grade < 60]; then
echo "$name $grade F"
elif [$grade >= 60||$grade < 70]; then
echo "$name $grade C"
elif [$grade >= 70||$grade < 80]; then
echo "$name $grade B"
elif [$grade >= 80||$grade <= 100]; then
echo "$name $grade A"
else
echo "Wrong input"
fi


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 04-14-2018 at 06:26 PM.. Reason: Added CODE tags.
# 2  
Old 04-14-2018
Hmmm - that request looks pretty much like homework.

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

If that request is NOT homework, please give some background and / or context for the request, like the research field the problem comes from, company or business category, or alike.

Thank You.

The UNIX and Linux Forums.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 04-14-2018
It is an exercise.

"Write a shell script program that will input a name and a mark between 0 and 100. The program then displays the name, the mark, and a letter grade for the mark, as per the following grade cut formula."

All am asking is a hint for my mistake.
# 4  
Old 04-14-2018
Quote:
Originally Posted by UniverseCloud
It is an exercise.

"Write a shell script program that will input a name and a mark between 0 and 100. The program then displays the name, the mark, and a letter grade for the mark, as per the following grade cut formula."

All am asking is a hint for my mistake.
Nonetheless, this is a question concerning a homework assignment and is not appropriate in this forum.

This thread is closed.

Continue any discussion on this topic in the thread Grades exercise.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Any help gratefully received

Multiple questions coming your way. A little back ground info as to why I am back to basics. A dear friend of mine passed away recently and as a request by him I have promised to keep his project alive. The problem I have it was being handed over when he was in the last weeks of his life and... (1 Reply)
Discussion started by: nobbyall
1 Replies

2. AIX

Error received when I was trying to check state of boot record

Hello, This is a test/lab LPAR. Recently installed and updated the SP/TL. everything seems to be working fine. (ran all post install checks) I checked the state of boot record, received the following error/failed message. Can you please explain what does this mean ? />ipl_varyon -i ... (1 Reply)
Discussion started by: dio34
1 Replies

3. HP-UX

Received error as Not enough space left on device

Hi Forum, We have observed one problem in one of our HP-UX machines which runs a software which connects the radio frequency scan devices and the scanned information is stored in the database through the same software. This software has thrown an error like "Not enough space left on the... (4 Replies)
Discussion started by: Nishant.Jvk
4 Replies

4. Shell Programming and Scripting

awk count how many IP have received that error

Hi all, I want to write a awk script that counts unique IPs that have received one special error. For example 25-04-2012;192.168.70.31;1254545454545417;500.0;SUCCESS 25-04-2012;192.168.70.32;355666650914;315126423993;;General_ERROR_23 30-04-2012;192.168.70.33;e;null;null;Failure... (4 Replies)
Discussion started by: arrals_vl
4 Replies

5. Shell Programming and Scripting

awk count how many unique IPs have received that error

Hi all, I want to write a awk script that counts unique IPs that have received one special error. For example 25-04-2012;192.168.70.31;1254545454545417;500.0;SUCCESS 25-04-2012;192.168.70.32;355666650914;315126423993;;General_ERROR_23 30-04-2012;192.168.70.33;e;null;null;Failure... (2 Replies)
Discussion started by: arrals_vl
2 Replies

6. AIX

nim: error signal number 2 received

Hi to all, i am trying to make mksysb backup of a NIM client machine from NIM master and while i am reading that the backup is done successfully i get an error message below and it doesnt exit the smit screen. also the status of the command appears to be running. is there anybody who knows why... (3 Replies)
Discussion started by: omonoiatis9
3 Replies

7. Solaris

"lpr.error] Warning: Received SIGPIPE" continuously appearing in logs

On a Solaris 8 print server we're continuously (every 2 minutes or so) getting these messages in the logs: printd: Warning: Received SIGPIPE; continuing I've applied this patch and restarted the printd daemon, but it doesn't help: #109320-22: SunOS 5.8: lp patch Does anyone have any idea what... (4 Replies)
Discussion started by: aussieos
4 Replies

8. Forum Support Area for Unregistered Users & Account Problems

no email received

I have tried to register and got a message saying an email would be sent but no email has turned up. Could you try again please? (1 Reply)
Discussion started by: lookingfor help
1 Replies

9. Solaris

Received duplicate M_IOCACK

Hi, I've got this message in /var/adm/messages... "genunix: Warning: 4a56a80 Received duplicate M_IOCACK" I get the messages maybe 6 times a day, or some days not at all. The number after "Warning:" is different each time. The system is Sun Blade 2500 running Solaris 9. I can't find... (0 Replies)
Discussion started by: omegad22
0 Replies

10. UNIX for Dummies Questions & Answers

sorting received mail in unix and another error

hello! when issuing the mail command to see my received mail, i get this error: (server)starla:/home/starla>mail Warning: Too many letters, overflowing letters concatenated msgcnt 27378 vxfs: mesg 001: vx_nospace - /dev/vg00/lvol4 file system full (1 block extent) mail: no space for temp file... (0 Replies)
Discussion started by: starla0316
0 Replies
Login or Register to Ask a Question