Skip to main content

GPA calculator in RUBY

#!/usr/bin/env ruby

=begin
Prgram : CGPA calculator
Date : May 16, 2014
Author : ManiG
License : GPL2.0
Version : 1.0
=end

sum=0.0
grade = {"S"=>10,"A"=>9,"B"=>8,"C"=>7,"D"=>6,"E"=>5,"U"=>0}
tot_credits = 0
tot_egrades = 0
print "enter no. of subjects : "
sub_count = gets().to_i
sub_count.times do |c|
    print "enter subject#{c+1}'s credit : "
    credit = gets().to_i
    tot_credits += credit
    print "enter subject#{c+1}'s earned grade :(only 'S','A','B','C','D','E','U') : "
    e_grade = gets().chomp.upcase
    tot_egrades += grade[e_grade] 
    sum += grade[e_grade]*credit
end
gpa = sum/tot_credits
puts
puts "Credits Earned #{tot_credits}"
puts "Grade points earned #{tot_egrades}"
puts "GPA #{format("%.4f",gpa)}"
puts "CGPA #{format("%.4f",gpa)}"
puts
puts "Percentage [=(cgpa*10)-7.5] #{format("%.4f",(gpa*10)-7.5)}"

Comments

Popular posts from this blog

கட்டற்றமென்பொருள் பற்றிய மாத மின்இதழ்

உலகெங்கிலும் உள்ள தமிழ் மக்களுக்கு கணினிதொழில்நுட்பத்தை பற்றி அறிமுகம் செய்யும் கணியம் என்ற புதிய மாத மின்னிதழை வெளியிடுவதில் பெருமகிழ்ச்சி அடைகிறோம். கணினி கற்க ஆங்கிலம் தடையாக இருந்த காலம் மாறி தொழில்னுட்பங்கள் யாவும் தமிழில் பெருகும் இந்த காலத்தில் மென்பொருள் பற்றிய நுட்பங்களை தமிழில் வழங்குவதில் பெருமை கொள்கிறோம். இந்த இதழின் கட்டுரைகள் : கட்டற்ற மென்பொருள் லினக்ஸ் பயனர் குழு – ஓர் அறிமுகம் உபுண்டு நிறுவுதல்

அழகான ASCII எழுத்துகளை டெர்மினலில் உருவாக்க

நம்முடைய மொபைலில் ascii smsகளை பார்த்து பிறருக்கும் அனுப்பி மகிழ்ந்திருப்போம். வெறும் எழுத்துகளை வைத்துகொண்டு படங்களை உருவாக்குவது மிகவும் கடினமான காரியம். குனு/லினக்ஸில் சில டூல்கள் இது போல அழகான ASCII எழுத்துகளையும், படங்களையும் உருவாக்க நமக்கு உதவுகிறது.  FIGLET   இதனை உபுண்டுவில் நிறுவ   $ sudo apt-get install figlet என கொடுத்து நிறுவி கொள்ளவும். உங்கள் பெயரினை ascii யில் பார்க்க டெர்மினலில் $ figlet 'hello'  என கொடுத்து பாருங்கள். _          _ _       | |__   ___| | | ___  | '_ \ / _ \ | |/ _ \ | | | |  __/ | | (_) | |_| |_|\___|_|_|\___/ எப்புடி.??  அடுத்து சில படங்களை ascii யாக மாற்றுவது என பார்போம்.  இதற்கு பல டூல்கள் இருக்கின்றது. உதாரணத்திற்கு aview, jp2a jp2a நிறுவ $ sudo apt-get install jp2a எதாவது ஒரு இமேஜை மாற்ற( இமேஜ் jpg பார்மட்டில் இருக்க வேண்டும்)   $ jp2a sample.jpg இப்போது asciiஇல் தெரியும்.

need your response

It has been a long time... my rest hours are reduced i only sleep for 5 to 6 hours a day.. so i can't post frequently.. sorry friends.. my university is a good place to refine myself. yes..! thoughts about my programming computers are refined there.. i always wanted share my experience.. but i feared of thinking that it will helpful for you or not.. most of us don't like to hear stories of others. so i stopped blogging and of course having less time.. i have earned some good friends there... who are interested in open-source technology.. very few of us only know the linux platform.. this semester mini project also in open softwares like mysql, postgrey sql i will start blogging my experience if you are interested.. regards, Mani G