Qbasicnews.com

Full Version: College Project
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
1. The grades are as follows:
< 45 grams - Reject
45 <= grams < 60 - Small
60 <= grams < 70 - Medium
70 <= grams < 86 - Large
86 >= grams - Jumbo
Use INPUT command to get the weight of each egg, and then print the weight and grade of the egg on the screen. Loop until the value of 0 grams is input, then print the number of eggs graded.

2. Whether a year is leap year or not.
Use IF statement and print the result of the test.
The rules for determining a leap year are as follows:
if a year is divisible by 4, it is a leap year, unless it is divisible by 100. If it is divisible by 100, it is not a leap year, unless it is also divisible by 400.
This should be in Newbie Help...

and usually, I don't condone blatantly doing someone else's work, but I'm really bored right now, so...

1.
[syntax="qbasic"]count = 0
do
input "Weight of egg (grams): ", weight
if weight = 0 then exit do
print "Weight:"; weight; " grams; grade: ";
if weight < 45 then
print "Reject"
elseif (weight >= 45) and (weight < 60) then
print "Small"
elseif (weight >= 60) and (weight < 70) Then
print "Medium"
elseif (weight >= 70) and (weight < 86) then
print "Large"
elseif (weight >= 86) then
print "Jumbo"
end if
count = count + 1
loop
print count; " eggs graded."[/syntax]
2.
[syntax="qbasic"]input "Enter year:", yr
if yr mod 4 then
if yr mod 100 then
if yr mod 400 then
print "Is a leap year"
else
print "Not a leap year
end if
else
print "Is a leap year"
end if
else
print "Is not a leap year."
end if[/syntax]
No! What are you doing DrV? Hows he gonna learn that way? He is just blantantly asking for answers. He didnt even say please. ffs.....(@mahesh)
Code:
defint a-z

dim weight as integer
dim rEggCount as integer
dim sEggCount as integer
dim mEggCount as integer
dim lEggCount as integer
dim jEggCount as integer


do
    input "Enter the weight of the egg: ", weight    
    
    if ( weight <= 0 ) then
        exit do
        
    elseif ( weight < 45 ) then
        rEggCount = rEggCount + 1
        print "Egg rejected"
    
    elseif ( (weight >= 45) and (weight < 60) ) then
        sEggCount = sEggCount + 1
        print "Small egg"
                
    elseif ( (weight >= 60) and (weight < 70) ) then
        mEggCount = mEggCount + 1
        print "Medium egg"
        
    elseif ( (weight >= 70) and (weight < 86) ) then
        lEggCount = lEggCount + 1
        print "Large egg"
        
    elseif ( weight >= 86 ) then
        jEggCount = jEggCount + 1
        print "Jumbo egg"
    end if
loop

print "Rejected eggs:" + str$( rEggCount )
print "Small eggs:"    + str$( sEggCount )
print "Medium eggs:"   + str$( mEggCount )
print "Large eggs:"    + str$( lEggCount )
print "Jumbo eggs:"    + str$( jEggCount )
print "Total number of eggs:" + str$( rEggCount+sEggCount+mEggCount+lEggCount+jEggCount )
Are those seriously college projects?
Quote:No! What are you doing DrV? Hows he gonna learn that way? He is just blantantly asking for answers. He didnt even say please. ffs.....(@mahesh)

I don't care... it's not my education that's at stake...
Quote:Are those seriously college projects?

Heh.


btw nice one Blitz... I'm too used to PHP and javascript arrays where you can just tack on more elements if you want.