Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Problem with writing a program Post 302233294 by CompNoob on Sunday 7th of September 2008 03:43:11 AM
Old 09-07-2008
Problem with writing a program

Hi guys
I'm having trouble with trying to create a script which calculates the grade of a student and the marks out of 300.
The grades are:
0-49% fail
50-59% pass
60-69% credit pass
70-79% distinction
80-100% high distinction
less than 0 or greater than 100 displays error message.

My problem is i don't know how to change the 300 into percentage form.

Here is my script that i have already made.

Image

P.S Andrew
 

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

I'm writing a new Linux program!

Yep, that's right. I'm writing a Linux binary that requires an X11 Server. It will also be released in a Shell, Win32, and Cocoa (Mac OS X). It's a program that's a text editor and more. It not just creates TXT and RTF files, it also can save in XML, RSS, and a whole lot of other formats. ... (11 Replies)
Discussion started by: Danny_10
11 Replies

2. UNIX for Dummies Questions & Answers

writing a program

i have written a very simple program in the vi editor, how do i now make it an executable file? (3 Replies)
Discussion started by: carlvernon
3 Replies

3. Shell Programming and Scripting

Need help on a program I'm writing

Hey guys.. I'm trying to learn how to script in bash... THIS IS NOT AN ASSIGNMENT but my instructor says to learn you must practice I'm trying to add to a program I'm writing that will print and save raw data... What syntax commands would I use to write them? And Thank you... (2 Replies)
Discussion started by: dmosheye
2 Replies

4. Shell Programming and Scripting

writing math testing program

Can anyone create a program that would test the math skills of the user. Assume that it would test integer addition, The program should ask the question,collect the integer response, evaluate and notify the user if their answer was correct or incorrect. I would assume integers in the range... (5 Replies)
Discussion started by: ccp
5 Replies

5. UNIX Desktop Questions & Answers

need help writing a program to look for doubles

to determine if two two doubles are equal, we check to see if their absolute difference is very close to zero. . .if two numbers are less than .00001 apart, theyre equal. keep a count field in each record (as you did in p5). once the list is complete, ask the user to see if an element is on... (2 Replies)
Discussion started by: rickym2626
2 Replies

6. Programming

writing a shell program in ubuntu

Hi all, I have an assignment from school to write a shell program in linux. the idea is to exercise fork() and execv() functions.. the shell program is supposed to be the master and every command that the user prints will run in a new process. we also need to try running the command in every... (1 Reply)
Discussion started by: r3vive
1 Replies

7. Programming

Writing C++ program Arguments and Classes

I want to write a C++ program that uses a class to do some calculations. I pass arguments to the program, some of which are used to set up class members. A class function will then perform the necessary calculations. I am wondering how I should pass the arguments from the program to set the... (2 Replies)
Discussion started by: kristinu
2 Replies

8. Homework & Coursework Questions

Help with writing a tee program in 4 hours

1. The problem statement, all variables and given/known data: Basic Assignment Write a program similar to the Unix "tee" command. Program The Unix "tee" command is used to pull out copies of a data stream. It is typically used in conjunction with pipes (analogous to a T-joint in plumbing, hence... (1 Reply)
Discussion started by: izzy077
1 Replies

9. Programming

Writing a search, copy and paste program

Hello, Can some one help me by writing me the script of a program that does the following simple functions on a Linux Mint: 1. it runs in the background all the time, doing nothing except of checking if there is any external device mounted. 2. when the device is detected, it copies files... (1 Reply)
Discussion started by: Black_Ardilla
1 Replies

10. Homework & Coursework Questions

Need help writing a shell script 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: Write the a shell script program to remove all space characters stored in the shell variable TEXT.... (7 Replies)
Discussion started by: kofine05
7 Replies
Class::DBI::FromCGI(3pm)				User Contributed Perl Documentation				  Class::DBI::FromCGI(3pm)

NAME
Class::DBI::FromCGI - Update Class::DBI data using CGI::Untaint SYNOPSIS
package Film; use Class::DBI::FromCGI; use base 'Class::DBI'; # set up as any other Class::DBI class. __PACKAGE__->untaint_columns( printable => [qw/Title Director/], integer => [qw/DomesticGross NumExplodingSheep/], date => [qw/OpeningDate/], ); # Later on, over in another package ... my $h = CGI::Untaint->new( ... ); my $film = Film->retrieve('Godfather II'); $film->update_from_cgi($h); my $new_film = Film->create_from_cgi($h); if (my %errors = $film->cgi_update_errors) { while (my ($field, $problem) = each %errors) { warn "Problem with $field: $problem "; } } # or $film->update_from_cgi($h => @columns_to_update); # or $film->update_from_cgi($h => { ignore => @cols_to_ignore, required => @cols_needed, all => @columns_which_may_be_empty }); my $how = $film->untaint_type('Title'); # printable DESCRIPTION
Lots of times, Class::DBI is used in web-based applications. (In fact, coupled with a templating system that allows you to pass objects, such as Template::Toolkit, Class::DBI is very much your friend for these.) And, as we all know, one of the most irritating things about writing web-based applications is the monotony of writing much of the same stuff over and over again. And, where there's monotony there's a tendency to skip over stuff that we all know is really important, but is a pain to write - like Taint Checking and sensible input validation. (Especially as we can still show a 'working' application without it!). So, we now have CGI::Untaint to take care of a lot of that for us. It so happens that CGI::Untaint also plays well with Class::DBI. Class::DBI::FromCGI is a little wrapper that ties these two together. METHODS
untaint_columns All you need to do is to 'use Class::DBI::FromCGI' in your class (or in your local Class::DBI subclass that all your other classes inherit from. You do do that, don't you?). Then, in each class in which you want to use this, you declare how you want to untaint each column: __PACKAGE__->untaint_columns( printable => [qw/Title Director/], integer => [qw/DomesticGross NumExplodingSheep/], date => [qw/OpeningDate/], ); (where the keys are the CGI::Untaint package to be used, and the values a listref of the relevant columns). update_from_cgi When you want to update based on the values coming in from a web-based form, you just call: $obj->update_from_cgi($h => @columns_to_update); If every value passed in gets through the CGI::Untaint process, the object will be updated (but not committed, in case you want to do anything else with it). Otherwise the update will fail (there are no partial updates), and $obj->cgi_update_errors will tell you what went wrong (as a hash of problem field => error from CGI::Untaint). create_from_cgi Similarly, if you wish to create a new object, then you can call: my $obj = Class->create_from_cgi($h => @columns_to_update); If this fails, $obj will be a defined object, containing the errors, as with an update, but will not contain the values submitted, nor have been written to the database. untaint_type my $how = $film->untaint_type('Title'); # printable This tells you how we're going to untaint a given column. cgi_update_errors if (my %errors = $film->cgi_update_errors) { while (my ($field, $problem) = each %errors) { warn "Problem with $field: $problem "; } } This returns a hash of any errors when updating. Despite its name it also applies when inserting. Column Auto-Detection As Class::DBI knows all its columns, you don't even have to say what columns you're interested in, unless it's a subset, as we can auto- fill these: $obj->update_from_cgi($h); You can also specify columns which must be present, or columns to be ignored even if they are present: $film->update_from_cgi($h => { all => @all_columns, # auto-filled if left blank ignore => @cols_to_ignore, required => @cols_needed, }); Doesn't this all make your life so much easier? NOTE
Don't try to update the value of your primary key. Class::DBI doesn't like that. If you try to do this it will be silently skipped. ANOTHER NOTE
If you haven't set up any 'untaint_column' information for a column which you later attempt to untaint, then we try to call $self->column_type to ascertain the default handler to use. Currently this will only use if you're using Class::DBI::mysql, and only for certain column types. SEE ALSO
Class::DBI. CGI::Untaint. Template. AUTHOR
Tony Bowden BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Class-DBI-FromCGI@rt.cpan.org COPYRIGHT
Copyright (C) 2001-2005 Kasei. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2005-10-04 Class::DBI::FromCGI(3pm)
All times are GMT -4. The time now is 04:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy