Sponsored Content
Full Discussion: Grades exercise
Homework and Emergencies Homework & Coursework Questions Grades exercise Post 303015916 by rbatte1 on Monday 16th of April 2018 12:33:41 PM
Old 04-16-2018
The problem in the case options you have defined is probably that it will be matching a regular (textual) expression, not a numeric range. Consider the characters that your variable is range than the value.


Does that help? A good case statement can make a wonderful replacement to if...then...elif...elif...elif...fi or lots of separate and confusing if statements. Just as good programming technique, your should follow this though and I would expect you would to get a better mark if you can crack it.



Robin
 

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
PREPROCESS(1)						      General Commands Manual						     PREPROCESS(1)

NAME
preprocess - Preprocess a file. SYNOPSIS
preprocess [options...] infile DESCRIPTION
Preprocess is like a typical C preprocessor, but it extends to multiple languages. Languages for which it works include: C++, Python, Perl, Tcl, XML, JavaScript, CSS, IDL, TeX, Fortran, PHP, Java, Shell scripts (Bash, CSH, etc.) and C#. Preprocess is usable both as a command line app and as a Python module. OPTIONS
-h, --help Print help text and exit. -V, --version Print the version info and exit. -v, --verbose Give verbose output for errors. -o outfile Write output to the given file instead of to stdout. -f, --force Overwrite given output file. Otherwise an IOError will be raised if outfile already exists. -D define Define a variable for preprocessing. define can simply be a variable name (in which case it will be true) or it can be of the form var=val. An attempt will be made to convert val to an integer so "-D FOO=0" will create a false value. -I dir Add a directory to the include path for #include directives. -k, --keep-lines Emit empty lines for preprocessor statement lines and skipped output lines. This allows line numbers to stay constant. -s, --substitute Substitute defines into emitted lines. By default substitution is NOT done because it currently will substitute into program strings. MODULE USAGE
from preprocess import preprocess preprocess(infile, outfile=sys.stdout, defines={}, force=0, keepLines=0, includePath=[], substitute=0) The <infile> can be marked up with special preprocessor statement lines of the form: <comment-prefix> <preprocessor-statement> <comment-suffix> where the <comment-prefix/suffix> are the native comment delimiters for that file type. EXAMPLES
HTML (*.htm, *.html) or XML (*.xml, *.kpf, *.xul) files: <!-- #if FOO --> ... <!-- #endif --> Python (*.py), Perl (*.pl), Tcl (*.tcl), Ruby (*.rb), Bash (*.sh), or make ([Mm]akefile*) files: # #if defined('FAV_COLOR') and FAV_COLOR == "blue" ... # #elif FAV_COLOR == "red" ... # #else ... # #endif C (*.c, *.h), C++ (*.cpp, *.cxx, *.cc, *.h, *.hpp, *.hxx, *.hh), Java (*.java), PHP (*.php) or C# (*.cs) files: // #define FAV_COLOR 'blue' ... /* #ifndef FAV_COLOR */ ... // #endif Fortran 77 (*.f) or 90/95 (*.f90) files: C #if COEFF == 'var' ... C #endif PREPROCESSOR SYNTAX
Valid statements: #define <var> [<value>] #undef <var> #ifdef <var> #ifndef <var> #if <expr> #elif <expr> #else #endif #error <error string> #include "<file>" where <expr> is any valid Python expression. The expression after #if/elif may be a Python statement. It is an error to refer to a variable that has not been defined by a -D option or by an in-content #define. Special built-in methods for expressions: defined(varName) Return true if given variable is defined. TIPS
A suggested file naming convention is to let input files to preprocess be of the form <basename>.p.<ext> and direct the output of prepro- cess to <basename>.<ext>, e.g.: preprocess -o foo.py foo.p.py The advantage is that other tools (esp. editors) will still recognize the unpreprocessed file as the original language. AUTHORS
Trent Mick <trentm@gmail.com> This manual page was written by Johannes Ring <johannr@simula.no> for the Debian GNU/Linux system (but may be used by others). PREPROCESS(1)
All times are GMT -4. The time now is 11:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy