Can Any help me with the math on this shell script?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Can Any help me with the math on this shell script?
# 1  
Old 12-10-2008
Can Any help me with the math on this shell script?

Develop a grade calculating program. This program will process all students in the file. This program should neatly display each field of each student's record *and* adds the following items: Course Average and Letter Grade. The course average is calculated by the following weights: 50% for quiz average, 20% for midterm, 10% for problems, and 20% for final exam. The letter grade is based on the normal grade brackets: 90/80/70/60.
# 2  
Old 12-10-2008
can you provide the sample data???
# 3  
Old 12-10-2008
i1000:TRINITY:JOAN K:92:92:93:90
1001:BLUMOFF:SAM Q:66:74:94:67
1002:PARTNEY:V C:84:82:100:50
1003:GRANT:RICK R:94:93:99:92
1004:TIPTON:FRED J:65:65:50:63
1005:KELSO:MIKE K:65:55:66:25
1006:STAGNER JR:DON K:85:95:97:87
1007:DONOVAN:CHESTER U:58:62:98:58
1008:MURRAY:TOM S:49:49:60:45
1009:SCHMALTZ:THEODORE:82:95:95:87
1010:MARTIN:WILBUR M:64:74:95:69
1011:HAFFER:LAURA S:72:75:96:70
1012:HALL:EDWARD C:64:65:99:66
1013:MONROE:PAT E:95:92:100:96
1014:BATES:MIKE W:83:92:96:88
1015:MILLMAN:MITCHELL H:67:71:98:68
1016:YOUNG:CLARK O:83:81:100:86
1017:BLAIR:JOHN P:65:73:93:68
1018:KING:PAT O:84:85:99:86
1019:MOORE:TED A:73:73:92:71
1020:DUFFY:GAIL H:57:51:98:54
1021:REINBERG:RON V:65:75:97:68
1022:GREWE:PAT E:73:84:94:77
1023:CLINTON:JOE A:84:94:92:88
1024:ELLIS:LEE E:64:65:94:63
1025:GRISHAM:STAN H:68:64:95:59
1026:GROSS:GENE H:68:51:92:55
1027:GROSSMAN:TIM U:74:81:94:77
1028:GROVE:GRACE O:83:81:95:83
1029:CORBET:LAURIE M:92:94:93:91
1030:WORKS:CINDY E:66:64:95:63
1031:KNEPPER:DON E:59:52:99:56
1032:SHOEMAKE:RHONDA C:67:72:97:67
1033:GULLY:LISA K:66:64:98:61
1034:JOHNSON:LINDA B:51:51:91:49
1035:DEVILLE:VICTOR M:57:51:100:53
1036:MEYER:MIKE D:57:64:91:59
1037:SWARTWOUT:JO I:83:82:98:84
1038:WHEAT:PATTI W:50:52:93:47
1039:CONNORS:STEPHEN X:65:65:98:63
1040:ADAMS:BRUCE X:84:91:99:89
1041:CIRAMI:ALICE N:50:51:94:49
1042:KUMMER:NATALIE P:58:52:91:56
1043:DUBINSKY:JULIE D:94:92:92:95
1044:WEBER:WILLIAM B:58:54:99:56
1045:HAGER:JOE U:65:75:95:67
1046:RISCH:SHARY Q:50:45:60:40
1047:ROWAN:ANGIE D:64:62:92:63
1048:LIENHOP:RICHARD C:50:53:96:49
1049:DANIS:MARK G:65:63:94:60
1050:HALL JR:DON D:93:91:93:94
1051:BREEN:CAROL C:56:53:94:54
1052:DANIELS:ROBERT J:65:65:93:63
1053:RHODES:BECKY N:92:95:96:93
1054:FLACH:JACK F:56:52:100:52
1055:HANNIGAN JR:CAROL:57:53:95:52
1056:WARNER:JAMES P:57:51:93:51
1057:WERNER:MICHELLE F:82:85:96:83
1058:LOVINS:JOLENE C:66:72:99:67
1059:BOIVIN:MARTIN J:56:53:91:53
1060:MEYSTRICK:TERRY H:49:53:93:48
1061:OWINGS:HAROLD P:66:75:99:68
1062:STEWART:VICKI D:84:95:93:88
1063:MCCLELLAN:PAT A:84:91:96:88
1064:HARRIS:NANCY M:81:83:100:82
1065:HARRISON:BRAD F:66:72:96:69
1066:HART:DEBBIE V:58:64:94:58
1067:HILLER:SIDNEY U:75:72:93:75
1068:SMITH:PAUL E:74:73:97:75
1069:TODOROVICH:MARY C:59:63:94:58
1070:HARTWIG:MATT L:72:82:93:79
1071:FOX:JEAN N:93:95:94:93
1072:TOBIN:JOHN Y:93:93:98:91
1073:HARMON:KEVIN U:58:54:95:52
1074:HAUMESSER:JEFF D:75:71:94:75
1075:HAYDEN:MARY R:51:51:100:48
# 4  
Old 12-10-2008
student#:LastName:Firstname:MiddleInitial:QuizAvg.:MidTermScore:ProblemScore:FinalExamScore
# 5  
Old 12-10-2008
try this.. it may help you..
format it bit more to get your desired output..
Code:
cat<<!
----------------------------------------------------------------------------------------------------------------------------------------------
STUDENT-ID      STUDENT NAME                QUIZ AVG       MIDTERM SCORE    PROBLEM SCORE    FINAM EXAM SCOR   COURSE AVERAGE        GRADE
----------------------------------------------------------------------------------------------------------------------------------------------
!
awk -F":" '{print $1":"$2":"$3":"$4":"$5":"$6":"$7":"($4/100)*50+($5/100)*20+($6/100)*10+($7/100)*20}' inputfile >tempfile
awk -F":" '$8>=90{printf("%4d\t\t%s %-15s\t\t%3d\t\t%3d\t\t%3d\t\t%3d\t\t%4f\t\tA\n",$1,$2,$3,$4,$5,$6,$7,$8);}$8>=80&&$8<90{printf("%4d\t\t%s %-10s\t\t%3d\t\
t%3d\t\t%3d\t\t%3d\t\t%f\t\tB\n",$1,$2,$3,$4,$5,$6,$7,$8);}$8>=70&&$8<80{printf("%4d\t\t%s %-15s\t\t%3d\t\t%3d\t\t%3d\t\t%3d\t\t%f\t\tC\n",$1,$2,$3,$4,$5,$6,$
7,$8);}$8>=60&&$8<70{printf("%4d\t\t%-s %-15s\t\t%3d\t\t%3d\t\t%3d\t\t%3d\t\t%f\t\tD\n",$1,$2,$3,$4,$5,$6,$7,$8);}' tempfile

# 6  
Old 12-10-2008
This looks like homework to me
# 7  
Old 12-19-2008
UNIX for Dummies///////thats me
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for solving the math question

Can such Puzzle solve through UNIX script? if yes, what could be the code? This has been solve in C language. we were trying to solve this through shell but could not because of not able to pass 1st argument with multiple value. we are not expert in unix scripting. Below is the puzzle John is a... (4 Replies)
Discussion started by: anshu ranjan
4 Replies

2. UNIX for Dummies Questions & Answers

Math

i have file (my_file.txt) that looks like this: 000000000000010000 000000000000010000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 000000000000005000 all said and one, it should look... (11 Replies)
Discussion started by: lawsongeek
11 Replies

3. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

5. UNIX for Dummies Questions & Answers

Variables and math in Old skool Bourne Shell

Hey everybody, I've been searching google and these forums and have found some solutions to the issues I've been having today within the OLD Bourne Shell. I am following chapter 6 of the Guide to Unix using Linux 4th Edition. I am working on some basic calculations with variables in the BASH... (3 Replies)
Discussion started by: mr.rhtuner
3 Replies

6. Shell Programming and Scripting

Math calculation over shell

Hi I am trying to calculate the rate at which something is happening. I have 2 files- a1 and b1. I want to calculate something like this ((wc -l a1)/(wc -l a1 + wc -l b1))*100 over a loop for different a and b. Is this possible, help me out fellas. Thanks a lot :) (5 Replies)
Discussion started by: jamie_123
5 Replies

7. Shell Programming and Scripting

A Math problem using shell script

Have a bit complicated math query .. Basically i am given a number which is > 50 .. I am suppose to find the calculation to get a number which is equal or more than the input number and is also a multiple of any number between 20 - 30 . For example . Input number is 60 . Now 20x3 =60 ... (2 Replies)
Discussion started by: greycells
2 Replies

8. Shell Programming and Scripting

Script math calculation

Hi Gurus, I'm currently using HP-UX B.11.23. I've a simple calculation script which performs the task below. -> echo "240021344 / 1024 /1024" | bc Output: 228 240021344 is KB value. When I tried to perform the same calculate in Ms Excel, it produces a different result: 228.9021912.... (12 Replies)
Discussion started by: superHonda123
12 Replies

9. Shell Programming and Scripting

math help

$ x=1 $ y=1.5 $ z=$((x*y)) bash: 1.5: syntax error: invalid arithmetic operator (error token is ".5") What's wrong? (2 Replies)
Discussion started by: rockbike
2 Replies

10. Programming

something about <math.h>

Hi, I got an easy problem for you but really difficult for me 'cause I am pretty new to this field I got header file <math.h> included in my .c file , then I write the code as below: k = sqrt(i); /* both variables k and i are int */ then I cc temp.c it says like this undefined... (4 Replies)
Discussion started by: blf0
4 Replies
Login or Register to Ask a Question