#!/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)}"
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
Comments
Post a Comment