Student Marks details using single inheritance program in Ruby


#Single Inheritance


class Marks
  def pass
    puts "\nEnter Maths Marks"
    mat=gets.to_i
    puts "Enter computer Marks"
    com=gets.to_i
    puts "Enter science Marks"
    sci=gets.to_i
    puts "\nTotal Marks:", tot=(mat.to_i + com.to_i + sci.to_i), "\n "
    if tot < 150
      puts "You are passed in second class"
    else
      puts "You are passed in first class"
    end
  end
end
class Student < Marks
  def pass
    puts "Enter the Rollno"
    no=gets.to_i
    puts "Enter the Name"
    name=gets
    puts "Enter the Depatment"
    dept=gets
    puts "\nRollno: #{ no}"
    puts "Name: #{ name}"
    puts "Depatment: #{ dept}"
    puts "\nHai "+ name +" \nPlease enter Marks" 
    super
  end
end
obj1=Student.new
obj1.pass

Comments

Popular posts from this blog

Php Form validation with Error messages with Checking fields.

Simple calculator using JQuery and HTML..

how to customize dashboard in active admin gem in rails 4