Small Grading Program

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Small Grading Program
# 1  
Old 03-31-2013
Small Grading Program

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:

1. Create a series of commands for a grading program.

Create a grades file. Put a "tab" between the name and grade. Run these commands directed to a file (>>).

Sam Smith A
Harry Konik B
Mike Grep C
Ann Smith A
Zed Arf F
Beth Mon B
Tod Bar C

a. Sort the list by last name
b. Sort the list by grade
c. Display all student's with A's
d. Display the number of students
e. Display the three top students
f. Display the two lowest grades
g. Display the list with the last name first followed by the first name then the grade.

2. Relevant commands, code, scripts, algorithms:

sort, grep(?)

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

Ok, before I start, I really am not sure what it means by "tab." Does it mean an actual tab, or a colon?

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

Brookdale Community College - Lincroft, New Jersey - United States - Dr. Rick Bournique- COMP 145


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).

---------- Post updated 03-31-13 at 09:01 PM ---------- Previous update was 03-30-13 at 10:26 PM ----------

Ok I created a file "namesfile" with tabs inbetween the first and lastname like so:

Code:
Sam     Smith A
Harry    Konik B
Mike     Grep C
Ann      Smith A
Zed      Arf F
Beth     Mon B
Tod      Bar C

My attempted solutions thus far:

a:
Code:
sort -k 1 namesfile

b:
Code:
sort -k 2 namesfile

d:
Code:
wc -l namesfile

c, e, f, and g are giving me a hard time, but I am still trying to figure them out.
# 2  
Old 03-31-2013
Read more carefully where it said to put the tab.

Yes, a tab means a tab, not a colon, as you figured out.
# 3  
Old 03-31-2013
Quote:
Originally Posted by Jagst3r21
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:

1. Create a series of commands for a grading program.

Create a grades file. Put a "tab" between the name and grade. Run these commands directed to a file (>>).

Sam Smith A
Harry Konik B
Mike Grep C
Ann Smith A
Zed Arf F
Beth Mon B
Tod Bar C

a. Sort the list by last name
b. Sort the list by grade
c. Display all student's with A's
d. Display the number of students
e. Display the three top students
f. Display the two lowest grades
g. Display the list with the last name first followed by the first name then the grade.

2. Relevant commands, code, scripts, algorithms:

sort, grep(?)

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

Ok, before I start, I really am not sure what it means by "tab." Does it mean an actual tab, or a colon?

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

Brookdale Community College - Lincroft, New Jersey - United States - Dr. Rick Bournique- COMP 145


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).

---------- Post updated 03-31-13 at 09:01 PM ---------- Previous update was 03-30-13 at 10:26 PM ----------

Ok I created a file "namesfile" with tabs inbetween the first and lastname like so:

Code:
Sam     Smith A
Harry    Konik B
Mike     Grep C
Ann      Smith A
Zed      Arf F
Beth     Mon B
Tod      Bar C

My attempted solutions thus far:

a:
Code:
sort -k 1 namesfile

b:
Code:
sort -k 2 namesfile

d:
Code:
wc -l namesfile

c, e, f, and g are giving me a hard time, but I am still trying to figure them out.
Is there a difference between putting[QUOTE]tabs inbetween the first and lastname[QUOTE]as you did when you created namesfile and the requirement to
Quote:
Put a "tab" between the name and grade.
?

It would be highly unusual for any IT professional to use the term "tab" to refer to a colon character.

Has you study of regular expressions enabled you to construct an RE matching a particular character at the end of a line?

You might want to get clarification as to whether the two lowest grades are D and F or the two lowest grades that have been assigned to class members. You might also want to clarify how you are to determine the top three students when there are two students with an A and two students with a B.

Assignment g would be much easier with awk, read and (echo or printf), or sed than with just grep and sort. (Of course I'm making assumptions about what shell you're using for your class. You haven't given us any indication of what shell and what operating system you're using.)
# 4  
Old 04-01-2013
You're right, thanks. I just thought it might be a colon, but it's not. A few things:

1) Why would adding the tab after the lastname matter though?

2) Is my solution to part d correct, or is counting the line numbers not accurate (NOTE: This is intro stuff so I tend to think if it's too easy it must be wrong, so this is probably the right solution(?))

3) For f, it is the two lowest grades that have been assigned to class members.

4) For e, I just emailed him to clarify.

5) For assignment G we have not learned awk yet. I'm 90% sure he does not want us using things we have not learned in class. So what on earth would I use, because many examples I googled use awk?
# 5  
Old 04-01-2013
Quote:
1) Why would adding the tab after the lastname matter though?
Read the instructions again from the professor for exactly where to put the tab. (Hint: the tab does NOT go after the first name Smilie).
Quote:
For assignment G we have not learned awk yet. I'm 90% sure he does not want us using things we have not learned in class. So what on earth would I use, because many examples I googled use awk?
If the assignment does not list awk as a possible solution, do NOT use awk. I'm 100% sure he does not want you using things you have not learned in class. What other commands have you learned in class?
# 6  
Old 04-01-2013
Quote:
Read the instructions again from the professor for exactly where to put the tab. (Hint: the tab does NOT go after the first name ).
I know, I updated it so it is after the last name there is a tab. I'm just wondering what the tab does Smilie

Quote:
What other commands have you learned in class?
Here are the commands that are relevant for this lab from the slide for this chapter:

File level commands:
Code:
pr
cmp, comm, diff
sort
uniq

Content level commands:

Code:
head,tail
cut, paste
tr
grep

# 7  
Old 04-01-2013
I'm very surprised that you have a class where you are learning about UNIX system utilities, but a shell isn't among the utilities you've been taught to use. As I said before, using your shell's built-in read and echo or printf utilities in a while loop would seem to be an obvious choice for some of these tasks.

I'm also very surprised that you are not allowed to use a text editor to create your input file (or, if you have been taught how to use an editor, that sed hasn't also been included in your list of available commands).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies

2. Shell Programming and Scripting

Making a bash script and small C program for a homework assignment

Here's the assignment. I'll bold the parts that are rough for me. Unfortunately, that's quite a bit lol. The syntax is, of course, where my issues lie, for the most part. I don't have a lot of programming experience at all :/. I'd post what I've already done, but I'm so lost I really don't know... (1 Reply)
Discussion started by: twk101
1 Replies

3. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

4. Shell Programming and Scripting

main program is not calling small other programs

I am trying to understand a program in a book and this program suppose to call other programs which are in the same folder, the other programs are called 'lu' and 'add' but for some reason when it gets to the last line of each case to call these programs there is an error message saying ./rolo:... (2 Replies)
Discussion started by: bartsimpsong
2 Replies

5. Programming

Python program faster than C++ program.

I wrote a simple program that generates a random word 10,000,000 times. I wrote it in python, then in C++ and compared the two completion times. The python script was faster! Is that normal? Why would the python script be faster? I was under the impression that C++ was faster. What are some of... (2 Replies)
Discussion started by: cbreiny
2 Replies

6. UNIX for Dummies Questions & Answers

Small Program with variables

Hello Geniuses of the unix world. please help, stupid chemist. I have the following script that I need to create a file. Doesnt make sense unless i explain this way: I need to create a file called summary.in I would like all these lines to be inserted however in the command line I would like the... (1 Reply)
Discussion started by: gingburg
1 Replies

7. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

8. Programming

A program to trace execution of another program

Hi, I wanted to know if i can write a program using switches and signals, etc to trace execution of other unix program which calls c program internally. If yes how? If not with signals and switches then are there any other methods apart from debugging with gdb/dbx. (3 Replies)
Discussion started by: jiten_hegde
3 Replies

9. Programming

execution small C++ program in UNIX

Hi my friends I am beginner unix programmer I have written small c++ program in text editor and I have change it mode to 555 to make it executable file to use it in unix O.P. #include<iostream.h> main() { cout<<"Hello World"; } but some syntax erroe came for << can any one help... (5 Replies)
Discussion started by: bintaleb
5 Replies

10. Shell Programming and Scripting

help me do a small program!! THX

Write a shell script (to run on the Bourne shell) that runs an infinite loop to check every 5 seconds to report on who logs into and who logs out of a UNIX system. Without loss of practical significance of this little utility, we can ignore multiple logins from the same user during a time period of... (1 Reply)
Discussion started by: lydragon
1 Replies
Login or Register to Ask a Question