|
|||||||
| Programming, Coding, (Web)Design Discuss all your programming or design needs with likeminded people. |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Delete Me
Join Date: Mar 2004
Posts: 14,648
Rep Power: 0 ![]() ![]() ![]() ![]() ![]() ![]() |
i have the world's easiest CS class
it's official...i have the world's easiest CS class ever. it's java based, btw...but here is our 'project', including the 'harder' option and the extra credit
![]() Code:
import cs1.Keyboard;
import java.text.DecimalFormat;
public class Project1
{
public static void main (String[] args)
{
final int speed = 2;
int yl, yw, hl, hw, ya, ha, ga;
float ttms, ttmm;
System.out.println ("Enter the length of the yard:");
yl = Keyboard.readInt();
System.out.println ("Enter the width of the yard:");
yw = Keyboard.readInt();
System.out.println ("Enter the length of the house:");
hl = Keyboard.readInt();
System.out.println ("Enter the width of the house:");
hw = Keyboard.readInt();
ha = hl*hw; //house area
ya = yl*yw; //yard area
ga = ya-ha; //grass area
ttms = ga/speed; //time to mow in seconds
ttmm = ttms/60; //time to mow in minutes
DecimalFormat threeDecPlcFormatter = new DecimalFormat("0.000");
System.out.println("The house dimensions were: " + hl + "x" + hw + " for an area of " + ha + " square feet.");
System.out.println("The yard dimensions were: " + yl + "x" + yw + " for an area of " + ya + " square feet.");
System.out.println("The area covered by grass is :" + ga + " square feet.");
System.out.println("It would take " + ttmm + " minutes to mow.");
System.out.println("Or, taken to 3 decimal places " + threeDecPlcFormatter.format(ttmm) + " minutes to mow.");
}
}
|
|
|
|
|
|
#2 |
|
confutatis maledictis
|
yeah that is simple, did you just start? and is it the first class in CS? I think it gets harder later
__________________
Digitalis 3.3 Athlon 64 3000 // ASUS K8V SE Deluxe // 1024MB PC3200 (2-2-2-10 1T)
ATI All-In-Wonder 9700 Pro // 20" Dell 2005FPW (DVI) M-Audio Revo 7.1 + Philips Acoustic Edge // Klipsch ProMedia 2.1 320/16 Western Digital WD3200KS + 120/8 Seagate 7200.7 NEC ND-3550A 16x DVD±RW + Lite-On 52x24x CD-RW Antec Sonata case // 480W Antec TruePower personal bests || Aq'3: 46796 | 3D'01: 20461 | 3D'03: 6336 | 3D'05: 2677 | PC'04: 4605 | PC'02: 7691,9092,1250 |
|
|
|
|
|
|
|
Delete Me
Join Date: Mar 2004
Posts: 14,648
Rep Power: 0 ![]() ![]() ![]() ![]() ![]() ![]() |
no, supposedly this is the 2nd...i skipped the 1st one
![]() and the rest of my class is kinda dim at times...like not knowing how to login to windows 2000
|
|
|
|
|
|
#4 |
|
BSD SMASH!
Join Date: May 2002
Location: A rabbit hole. . .
Posts: 1,170
Rep Power: 0 ![]() |
It better get harder.
So far, I hsven't done a vast array of cool stuff in college, but I have written an AI for Scrabble (in Java), a few different solutions to the satisfiability problem, including WalkSAT, and a CMS in PHP/MySQL. You usually don't do the cool stuff until you take restricted electives or upper level courses.
__________________
quad (FreeBSD/amd64 8-CURRENT): Intel Q6600 - Asus P5E-VM HDMI - 2x2 GB Kingston PC6400 DDR2 Ram - Seagate 320GB 7200RPM HD - 2xSeagate 1TB 7200RPM HD in RAID 1 via ZFS - Lite-On 20x DVD Multi Recorder - Coolermaster Centurion 5 router (FreeBSD/amd64 8-CURRENT): Intel E4500 - Intel D945GCNL - 2 GB PC6400 Mushkin Ram - Lite-On 48x24x48x16 - Seagate 320GB 7200RPM HD - Silverstone SST-SG02-F wanderer (FreeBSD/i386 7-CURRENT): Lenovo Thinkpad T61p mini (OS X 10.5): Intel Core 2 Duo @ 1.8Ghz, 4 GB Mushkin PC5400 Ram - Headroom MicroDAC Portable sound: Rockboxed iPod Video -> Westone UM2's Not-So-Portable Sound: Headroon MicroDAC -> Singlepower PPX3-SLAM -> Grado RS-1's or Beyerdynamic DT-880's Very-Not-Portable-Sound: Squeezebox v3 -> Denon AVR-1507 -> B&W 683's & Sunfire HRS-10 |
|
|
|
|
|
|
|
Delete Me
Join Date: Mar 2004
Posts: 14,648
Rep Power: 0 ![]() ![]() ![]() ![]() ![]() ![]() |
yea...it'll get lots harder come next year anbd the year after...i just want it to get harder faster b4 i fall asleep
|
|
|
|
|
|
#6 |
|
HH Administrator
|
Yea I had that in a module last year, teaching us html, I'm not even talking XHTML or remotely complicated. table's were the most complicated tag we hit, pity I learned html bout 6 years ago
|
|
|
|
|
|
|
|
Delete Me
Join Date: Mar 2004
Posts: 14,648
Rep Power: 0 ![]() ![]() ![]() ![]() ![]() ![]() |
yea, i learned a good bit of java about 2-3 years ago..so this is sad and pathetic...lol
|
|
|
|
|
|
#8 |
|
Forged on Dragonmount
|
I feel sorry for you pj, LOL, but then again, I'll be in the same boat as well next year.
__________________
![]() |
|
|
|
|
|
#9 |
|
DriverHeaven Senior Member
Join Date: Dec 2004
Location: Inside DriverHeaven
Posts: 856
Rep Power: 0 ![]() ![]() |
*sigh* reminds me of my first semester in CS... everything was much simpler then
__________________
|
|
|
|
|
|
|
|
Delete Me
Join Date: Mar 2004
Posts: 14,648
Rep Power: 0 ![]() ![]() ![]() ![]() ![]() ![]() |
it's gotten a LITTLE harder now(new semester)...but the hardest thign we've hit yet is a very little bit of inheritance, such as using the 'super' / 'extends' command
|
|
|
|
|
|
#11 |
|
I Have lovely Breasts
Join Date: Jul 2004
Location: In the closet...
Posts: 5,395
Rep Power: 64 ![]() ![]() ![]() ![]() ![]() ![]() |
dude when I read the topic title I thought "They offer Counter-Strike classes?! what?! SIGN ME UP!!!"
__________________
|
|
|
|
|
|
#12 | |
|
DriverHeaven Junior Member
Join Date: Jul 2002
Location: Derby UK
Posts: 78
Rep Power: 0 ![]() |
Quote:
but if you find it easy then surely thats a good thing it means you'll pass really easily with A+ all the way
__________________
AMD Athlon64 X2 4200+ 1GB OCZ Platinum x2 74Gb WD Raptors RAID0 256mb Radeon X1300 Sapphire Pure Innovation M-Audio Revolution 7.1 Windows XP x64 Edition |
|
|
|
|
|
|
#13 |
|
Anti-Piracy Poster Boy
|
Polymorphism is nothing. Just wait until you're writing your own compiler for a small subset of the pascal language. And it's 80% of your grade.
__________________
"It is because the resistance to paying for copyrighted material, although often characterized as arising from a supposed technical burden or principled concern for the public interest, arises rather from exactly the same segment of the brain that is dominant in shoplifters." - Mark Helprin, Digital Barbarism In other words, it's never okay to steal even if you think you have a good reason! www.yayitsandrew.com
|
|
|
|
|
|
|
|
Delete Me
Join Date: Mar 2004
Posts: 14,648
Rep Power: 0 ![]() ![]() ![]() ![]() ![]() ![]() |
lol...we're not quite to polymorphism yet...that comes in a few weeks
|
|
|
|
|
|
#15 | |
|
DriverHeaven Junior Member
Join Date: Jul 2002
Location: Derby UK
Posts: 78
Rep Power: 0 ![]() |
Quote:
__________________
AMD Athlon64 X2 4200+ 1GB OCZ Platinum x2 74Gb WD Raptors RAID0 256mb Radeon X1300 Sapphire Pure Innovation M-Audio Revolution 7.1 Windows XP x64 Edition |
|
|
|
|
|
|
#16 |
|
DriverHeaven Newbie
Join Date: Apr 2005
Location: Salem
Posts: 6
Rep Power: 0 ![]() |
I'm in CS at RIT and this coding will give you an F due to lack of comments. In my CS courses, every thing you do even the "hello world" requires you to comment in. But regardless are you sure you're taking the general CS, well what college are you in? I'm just wondering only because you said that you've skipped the basics and I'm telling you, your code ARE BASIC. I could post in one of my code and FYI, this is from the beginner course of Java Programming. There are two different files and I am not perfect and the code is not perfect but I would say 90% correct in most case, the only thing wrong with it is the ranking system.
Code:
//Purpose: Homework #7
//Coder: XXXXXXXX XXXXX
//Professor: Mr.French
//Date: 02-07-2005
//imprting a file
import javax.swing.*;
public class TestQuarterback
{
public static void main(String[] args)
{
//New Object of QuARTERBACK CLASS
Quarterback run = new Quarterback();
run(run);
}
public static void run(Quarterback run) {
//Menu Variable
int menuChoice = 0; //Variable that determines which aspect of program to execute...
//Run Menu Choice
menuChoice = MyInputPane.readInt("Options:"
+ "\n1.Update Quarterback statistics"
+ "\n2.Print Average Pass Yardage"
+ "\n3.Print Completed Passes Percentage"
+ "\n4.Print Touchdown Passes Percentage"
+ "\n5.Print Intercepted Passes Percentage"
+ "\n6.Print Quarterback Rating"
+ "\n7.Print Current Statistics"
+ "\n8.Exit Program \nEnter Options:");
//Validatining MenuChoice
while (!(menuChoice > 0 && menuChoice < 9))
{
//runs menu choice again
MyInputPane.displayMessage("An Invalid Value Entered");
menuChoice = MyInputPane.readInt("ERROR, ENTER 1-8 ONLY"
+ "\n Options: "
+ "\n1.Update Quarterback statistics "
+ "\n2.Print Average Pass Yardage "
+ "\n3.Print Completed Passes Percentage "
+ "\n4.Print Touchdown Passes Percentage "
+ "\n5.Print Intercepted Passes Percentage "
+ "\n6.Print Quarterback Rating "
+ "\n7.Print Current Statistics "
+ "\n8.Exit Program "
+ "\nEnter Options:");
}//ends while validatining menuChoice
//while loop runs switch loop until 8 is entered then it kills program and exit
while(menuChoice != 8)
{
//switch loop decides which aspect of program to execute
switch (menuChoice)
{
case 1: while (!run.setPassAttempt(MyInputPane.readDouble("Year to date:\n Number of passing attempts")))
{}
while (!run.setCompletedPass(MyInputPane.readInt("Number of Complete Pass")))
{}
while (!run.setTotalPassYard(MyInputPane.readInt("Pass Yardage")))
{}
while (!run.setTouchdownPass(MyInputPane.readInt("Number of Touchdown Pass")))
{}
while (!run.setPassInt(MyInputPane.readInt("Number of Pass Intercepted")))
{}
run(run);
//Run Menu Choice
break;
case 2: MyInputPane.displayMessage("Average Passing Yardage : " + (run.getTotalPassYard() / run.getCompletedPass()));
run(run);
//Run Menu Choice
break;
case 3:MyInputPane.displayMessage("Completed Passing Percentage : " + (run.getCompletedPass() / run.getPassAttempt()));
run(run);
//Run Menu Choice
break;
case 4:MyInputPane.displayMessage("Touchdown Pass Percentage : " + (run.getTouchdownPass() / run.getPassAttempt()));
run(run);
//Run Menu Choice
break;
case 5:MyInputPane.displayMessage("Intercepted Pass Percentage : " + (run.getPassInt() / run.getPassAttempt()));
run(run);
//Run Menu Choice
break;
case 6:MyInputPane.displayMessage("Quarterback Rating : " + (((((run.getCompletedPass() / run.getPassAttempt())) * .05)+(((run.getTotalPassYard() / run.getPassAttempt())-3)* .25)+((run.getTouchdownPass() / run.getPassAttempt())* .2)+(((run.getPassInt() / run.getPassAttempt())*.25)- 2.375)/10)*100));
run(run);
//Run Menu Choice
break;
case 7:MyInputPane.displayMessage("Current Quarterback Statistic:"
+ "\nQuarterback Pass Attempts : " + run.getPassAttempt()
+ "\nQuarterback Pass Completed : " + run.getCompletedPass()
+ "\nTotal Yard Passed : " + run.getTotalPassYard()
+ "\nCompleted Touchdown Passes : " + run.getTouchdownPass()
+ "\nTotal Pass Intercepted : " + run.getPassInt());
run(run);
//Run Menu Choice
break;
case 8: System.exit(0);
break;
}//ends switch loop
}//Ends while loop
System.exit(0);
//Exits the program...
}//Ends main method
}//Ends class file
Code:
//Purpose: Homework #7
//Coder: XXXXXXXX XXXXX
//Professor: Mr.French
//Date: 02-07-2005
public class Quarterback
{
//Attributes are private
private double numPassAttempt; //Number of Pass Attempt
private double cmplPass; //Completed Pass
private double totalYard; //Total Passing Yardage
private double touchdownPass; //Touchdown Pass
private double passInt; //Number of Pass Intercepted
//default constructor
public Quarterback()
{
numPassAttempt = 0;
cmplPass = 0;
totalYard = 0;
touchdownPass = 0;
passInt = 0;
}
// --------------------------- //
//All Accessors Are Listed Here
// --------------------------- //
//Number of Pass Attempt
public double getPassAttempt()
{
return numPassAttempt;
}
//Number of Completed Pass
public double getCompletedPass()
{
return cmplPass;
}
//Total Pass Yardage
public double getTotalPassYard()
{
return totalYard;
}
//Number of Touchdown Passes
public double getTouchdownPass()
{
return touchdownPass;
}
//Number of Pass Intercepted
public double getPassInt()
{
return passInt;
}
//All Mutators Are Listed Here
// ------------------------- //
//Number of Pass Attempts
public boolean setPassAttempt(double passAttempt)
{
if (passAttempt >= 0)
{
numPassAttempt = passAttempt;
return true;
}
return false;
}
//Number of pass completed
public boolean setCompletedPass(int complPass)
{
if (cmplPass >= 0)
{
cmplPass = complPass;
return true;
}
return false;
}
//Pass Yardage
public boolean setTotalPassYard(int totalYardage)
{
if (totalYardage >= 0)
{
totalYard = totalYardage;
return true;
}
return false;
}
//Number of Touchdown Pass
public boolean setTouchdownPass(int tdPass)
{
if (tdPass >= 0)
{
touchdownPass = tdPass;
return true;
}
return false;
}
//Number of Pass Intercepted
public boolean setPassInt(int intPass)
{
if (intPass >= 0)
{
passInt = intPass;
return true;
}
return false;
}
/**
formula for qb ranking
subtract 30 from qb passsing ranking then multiply by .05
subtract 3 from qb yards per attempt and multiply by .25
divide qb number of touchdown passes by his number of passing attempts
multiplly percentage of touch down passes per attempt by .2
multiply his interception percentage by .25
add final 4 numbers in each category
divide by 10 then multiply by 100 [yeilds qb rating]
*/
}
or of any that sort. Java's fun and nice. I wish you the uttermost luck in the course. Oh on a side note I recieved a C grade for this homework only due to two things, not enough of comments and the ranking system is not correct.
Last edited by Jon855; Apr 27, 2005 at 01:26 PM. |
|
|
|
|
|
#17 | |
|
BSD SMASH!
Join Date: May 2002
Location: A rabbit hole. . .
Posts: 1,170
Rep Power: 0 ![]() |
Quote:
__________________
quad (FreeBSD/amd64 8-CURRENT): Intel Q6600 - Asus P5E-VM HDMI - 2x2 GB Kingston PC6400 DDR2 Ram - Seagate 320GB 7200RPM HD - 2xSeagate 1TB 7200RPM HD in RAID 1 via ZFS - Lite-On 20x DVD Multi Recorder - Coolermaster Centurion 5 router (FreeBSD/amd64 8-CURRENT): Intel E4500 - Intel D945GCNL - 2 GB PC6400 Mushkin Ram - Lite-On 48x24x48x16 - Seagate 320GB 7200RPM HD - Silverstone SST-SG02-F wanderer (FreeBSD/i386 7-CURRENT): Lenovo Thinkpad T61p mini (OS X 10.5): Intel Core 2 Duo @ 1.8Ghz, 4 GB Mushkin PC5400 Ram - Headroom MicroDAC Portable sound: Rockboxed iPod Video -> Westone UM2's Not-So-Portable Sound: Headroon MicroDAC -> Singlepower PPX3-SLAM -> Grado RS-1's or Beyerdynamic DT-880's Very-Not-Portable-Sound: Squeezebox v3 -> Denon AVR-1507 -> B&W 683's & Sunfire HRS-10 |
|
|
|
|
![]() |
| Thread Tools | |
|
|