Sponsored Content
Full Discussion: Grades exercise
Homework and Emergencies Homework & Coursework Questions Grades exercise Post 303015862 by UniverseCloud on Saturday 14th of April 2018 05:51:37 PM
Old 04-14-2018
Question Grades exercise

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

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.

2. Relevant commands, code, scripts, algorithms:

case/read/echo/if

3. The attempts at a solution (include all code and scripts):

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



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Sheridan college, Oakville, canada, Syed tanbeer, ["https://academics.sheridancollege.ca/programs/computer-systems-technology-software-development-and-network-engineering"

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[question] trouble with an 'exercise'

Hello guys.. well, im kinda newbie with unix because i started to learn it like 2 weeks ago. then i started to make some exercises, but i got stucked on this one : so, i need to know how many different 'names' has the 5th field and how many times each name appears. i was trying with a... (6 Replies)
Discussion started by: EnioMarques
6 Replies

2. UNIX for Dummies Questions & Answers

[question] hard exercise, help needed

Hello guys. Well, on this exercise i need the average "chargeAmount" per hour (for each hour). with this code : cat getusagesummarywrongmatch | grep -iv MOU2GRTObject | cut -d'|' -f4,14 | grep -i chargeamount | cut -d' ' -f2 http://img227.imageshack.us/img227/5889/65969235do0.jpg i got... (2 Replies)
Discussion started by: EnioMarques
2 Replies

3. Shell Programming and Scripting

Reading 5 Students names and grades using while loop????

How do I write a shell script file to read 5 student names (First and Last name) and their grades using a While Loop? Find the Average, Maximum, and Minimum of grades using the same While Loop. Prompt the user using tput to enter the information (first name, last name, grade). Save the data in a... (1 Reply)
Discussion started by: dlbomber1
1 Replies

4. Shell Programming and Scripting

Trouble with part of an exercise

Hi, 'm trying to do an exercicise, and one part is: ls -l $1 | awk ' BEGIN { max = $5; } { if ($5 > max){ max = $5; } } END { print "Tamanio mayor fichero = " max; }' # Imprimimos ahora el menor tamaņo de fichero ls -l $1 | awk '... (4 Replies)
Discussion started by: Phass
4 Replies

5. Homework & Coursework Questions

Help with this exercise

you are to write a program which will read in a tax rate (as a percentage) and the prices of 5 items. the program is to calculate the total price, before tax, of the items and then the tax payable on those items, and then the total amount due. the tax payable is computed by appliying the tax rate... (1 Reply)
Discussion started by: bunkercrazy
1 Replies

6. Shell Programming and Scripting

A very tough exercise

hello everyone!:) I have an exercise which I think is difficult for beginner like me. Here is the exercise Create a shell script, which takes a directory as command line argument. Script displays ten first lines from every text file in that directory. After displaying the lines from the... (1 Reply)
Discussion started by: googlevn
1 Replies

7. UNIX for Dummies Questions & Answers

UNIX Exercise

Hi, I am learning unix. I want to practice few small excercises. Please suggest me some goor URL to practice. Thanks in advance. (1 Reply)
Discussion started by: stew
1 Replies
Command(4)						     Kernel Interfaces Manual							Command(4)

NAME
Command - Contains file transfer directions for the uucico daemon SYNOPSIS
/usr/spool/uucp/LocalSystemName/C.SystemNamexxxx### DESCRIPTION
Command (C.*) files contain the directions that the uucp uucico daemon follows when transferring files. The full pathname of a command file is a form of the following: /usr/spool/uucp/SystemName/C.SystemNameNxxxx /C.SystemName indicates the name of the remote system. N represents the grade of the work, and xxxx is the 4-digit hexadecimal transfer- sequence number; for example, C.merlinCE01F. The grade of the work specifies when the file is to be transmitted during a particular connection. The grade notation has the following characteristics: It is a single number (0 to 9) or letter (A to Z, a to z). Lower sequence characters cause the file to be transmitted earlier in the connection than do higher sequence characters. The number 0 (zero) is the highest grade, signifying the earliest transmit- tal; z is the lowest grade, signifying the latest transmittal. The default grade is N. A command file consists of a single line that includes the following kinds of information in the following order: An S (send) or R (receive) notation. Note that a send command file is created by the uucp or uuto commands; a receive command file is created by the uux command. The full pathname of the source file being transferred. A receive command file does not include this entry. The full pathname of the destination file, or a pathname preceded by ~user (tilde user), where user is a login name on the specified system. Here, the tilde is shorthand for the name of the user's home directory. The sender's login name. A list of the options, if any, included with the uucp, uuto, or uux command. The name of the data file associated with the command file in the spooling directory. This field must contain an entry. If one of the data-transfer commands (such as the uucp command with the default -c flag) does not create a data file, the uucp pro- gram instead creates a placeholder with the name D.0 for send files, or dummy for receive files. The source file permissions code, speci- fied as a 3-digit octal number (for example, 777). The login name of the user on the remote system who is to be notified when the transfer is complete. EXAMPLES
Examples of send command and receive command files follow. Examples of Two Send Command Files The send command file /usr/spool/uucp/venus/C.heraN1133, created with the uucp command, contains the following fields: S /u/betp/f1 /usr/spool/uucppublic/f2 betp .nL -dC D.herale3655 777 jmp The fields are as follows: The S keyword denotes that the uucp command is sending the file. The full pathname of the source file is /u/betp/f1. The full pathname of the destination is /usr/spool/uucppublic/f2, where /usr/spool/uucp- public is the name of the uucp public spooling directory on the remote computer and f2 is the new name of the file. Note that when the user's login ID is uucp, the destination name may be abbreviated as ~ uucp/f2. Here, the ~ (tilde) is a short- hand way of designating the public directory. The person sending the file is betp. The sender entered the uucp command with the -C flag, specifying that the uucp command program should transfer the file to the local spooling directory and create a data file for it. (The -d flag, which specifies that the command should create any intermediate directories needed to copy the source file to the destination, is the default.) The name of the Data (D.*) file is D.herale3655, which the uucp command assigns. The octal permis- sions code is 777. On system hera, jmp is the login name of the user who is to be notified of the file arrival. The /usr/spool/uucp/hera/C.zeusN3130 send command file, produced by the uuto command, is as follows: S /u/betp/out ~/receive/msg/zeus betp .nL -dcn D.0 777[4~ msg The S denotes that the /u/betp/out source file was sent to the receive/msg subdirectory in the public spooling directory on system zeus by user betp. The uuto command used the default flags -d (create directories), -c (transfer directly, no spooling directory or data file), and -n (notify recipient). Note that the uuto command creates the receive/msg directory if it does not already exist. The D.0 notation is a placeholder, 777 is the permissions code, and msg is the recipient. Example of a Receive Command File The format of a receive command file is somewhat different from that of a send command file. When files required to run a specified com- mand on a remote system are not present on that system, the uux command creates a receive command file. For example, the following command produces the /usr/spool/uucp/zeus/C.heraR1e94 receive command file: uux - "diff /u/betp/out hera!/u/betp/out2 > ~uucp/DF" Note that the command in this example invokes the uux command to run a diff command on the local system, comparing file /u/betp/out with file /u/betp/out2, which is stored on remote system hera. The output of the comparison is placed in file DF in the public directory on the local system. The actual receive command file looks like this: R /u/betp/out2 D.hera1e954fd betp - dummy 0666 betp The R denotes a receive file. The uucico daemon, called by the uux command, gets the /u/betp/out2 file from system hera, and places it in a data file called D.hera1e954fd for the transfer. Once the files are transferred, the uuxqt daemon executes the command on the specified system. User betp issued the uux command with the - (dash) flag, which makes the standard input to the uux command the standard input to the actual command string. No data file was created in the local spooling directory, so the uucp program uses dummy as a placeholder. The permissions code is 666 (the uucp program prefixes the 3-digit octal code with a 0 [zero]), and user betp is to be notified when the command finishes executing. FILES
Describes access permissions for remote systems Describes accessible remote systems Contains uucp command, data, and execute files Contain data to be transferred Contains transferred files RELATED INFORMATION
Commands: uucp(1), uupick(1), uuto(1), uux(1), uuxqt(1), uudemon(4), cron(8), uucico(8), uusched(8) delim off Command(4)
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy