Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-29-2007, 02:10 PM
A.N.H A.N.H is offline
Newbie
 
Join Date: Apr 2007
Posts: 8
Rep Power: 0
A.N.H is on a distinguished road
Post The latest program i wrote!!

here is the latest program i wrote, its a teaching instructor for math operations, u can chose your level skill, it will calculate your score after ten answer (or more if u get stuck in one), and comments on your answers, i know its kinda basic (since i still dont know how to program using array and stuff like, that i will teach myself these things soon though), anywayz can u check it out, tips, hints and stuff like that is more then welcomed of course.

Code:
import java.util.Scanner;
import java.util.Random;


public class Quiz 
{
	int level;
	int cho;
	int Num1;
	int Num2;
	int Add;
	int Sub;
	double Div;
	int Mul;
	int NumofCorrect = 0;
	double precen= NumofCorrect / 10;
	int counter = 0;
	
	private void incaseright( int x )
	{
		switch ( x )
		{
		case 4:
			System.out.println("You gots it bro, you gots it, lets do another 1");
			break;
		case 3:
			System.out.println("Call the fire department, this guy is on fire, lets c if u can do this");
			break;
		case 2:
			System.out.println("THAT IS WRONG!!!, kidding your right dawg, try this 1");
			break;
		case 1:
			System.out.println("if i could buy u a lapdance i would, goodjob bro, get this right & i just might");
			break;
		default:
			System.out.println("Who is your daddy, its you dawg!!, now solve this");
		}		
		
	}
	
	private void incasewrong( int x )
	{
		switch ( x )
		{
		case 0:
			System.out.println("What has u been smoking!!, try again");
			break;
		case 1:
			System.out.println("****, your wrong...i should have bet on someone else, again");
			break;
		case 2:
			System.out.println("you call that an answer, my dog can answer better than u, try m8");
			break;
		case 3:
			System.out.println("stop looking at that hot gal beside u and focus, gal like to date smart lads, try again");
			break;
		default:
			System.out.println("yo dawg, concentrate, u can do it, i think..., try again");
			
		}
	}
	
	
	
	
	private void GenerateQ()
	{
		
		
		Random rand = new Random();
		
		Num1 =  level *(rand.nextInt(11) );
		Num2 = level * (1 + rand.nextInt(11) );
		Mul = Num1 * Num2;
		Div = Num1 / Num2;
		Sub = Num1 - Num2;
		Add = Num1 + Num2;
		
		if ( counter >= 10 )
		{
			System.out.printf("you answered %d times baby-cuz\n", counter);
			if ( precen < .75 )
			{
				System.out.printf("Yo dawg u need to study more your score is %.2f...NEXT!!", precen );
			}
			else
			{
				System.out.printf("man your good, i'll keep an eye on u, your score is %.2f ...next", precen);
			}
		}
		else
		{
			
			System.out.printf("you answered %d times baby-cuz\n", counter);
			ChooseOp();
			
		System.out.printf("How much is %d ", Num1); 
		
		ChooseOp2();
		
		System.out.printf("%d\n", Num2);
		
	}
}
	
	public void Chooselevel()
	{
		Scanner input = new Scanner ( System.in );
		
		
		System.out.println("Yo Yo, chose your level dawg");
		System.out.println("the input must be in base 10, for example: if u chose level 10\n"
				+"your question is to find an answer of 2 TWO-DIGIT numbers\n"+
				"if your lvl is 100, u need to find an answer of 2 THREE-DIGIT numbers\n"
				+"u gots it dawg!!");
		
		
		level = input.nextInt();
				
				
	}
	
	
	
	
	private void ChooseOp()
	{
		
		System.out.println("Choose an operation dawg\n0 to divide\n1 to multiply\n" +
				"2 to subtract\n3 to add, c'mon lets play\nIncase of division round to the nearest decemal m8");
		Scanner input = new Scanner ( System.in );
		cho = input.nextInt();
	}
	
	private void ChooseOp2()
	{
		
		switch ( cho )
		{
		case 0:
			System.out.print("divided by ");
			break;
		case 1:
			System.out.print("times");
			break;
		case 2:
			System.out.print("subtracted by ");
			break;
		default:
			System.out.print("added to ");
		}
	}
	
	
	private void ifWrong()
	{
	
		Random rad = new Random();
		incasewrong( rad.nextInt(5) );
		
		
		int answer2;
		Scanner input = new Scanner( System.in );
		answer2 = input.nextInt();
		
		
		if ( cho == 0 )
		{
			if ( answer2 == Math.floor ( Div * 10 + 0.5 ) / 10)
			{
				System.out.println("whos a good boy, who is, who is");
				NumofCorrect++;
				counter++;
				ask();

			}
			else 
			{
				counter++;
				ifWrong();
			}
		}
		
		
		
		if ( cho == 1 )
		{
			if ( answer2 == Mul )
			{
				System.out.println("whos a good boy, who is, who is");
				NumofCorrect++;
				counter++;
				ask();

			}
			else 
			{
				counter++;
				ifWrong();
			}
		}
		
		
		if ( cho == 2 )
		{
			if ( answer2 == Sub )
			{
				System.out.println("whos a good boy, who is, who is");
				NumofCorrect++;
				counter++;
				ask();

			}
			else 
			{
				counter++;
				ifWrong();
			}
		}
		
		if ( cho == 3 )
		{
			if ( answer2 == Add )
			{
				System.out.println("whos a good boy, who is, who is");
				NumofCorrect++;
				counter++;
				ask();

			}
			else 
			{
				counter++;
				ifWrong();
			}
		}
		
	}
	
	
	
	
	public void ask()
	{
		GenerateQ();
		
		Random radd = new Random();
		
		int answer;
		Scanner input = new Scanner ( System.in );
		answer = input.nextInt();
		
		if ( cho == 0 )
		{
			if ( answer == Math.floor( 10 * Div + 0.5 )/10 )
			{
				incaseright( radd.nextInt(5));
				NumofCorrect++;
				counter++;
				ask();
			}
			else 
			{
				counter++;
				ifWrong();
			}
		}
		
		if ( cho == 1 )
		{
			if ( answer == Mul )
			{
				incaseright( radd.nextInt(5));
				NumofCorrect++;
				counter++;
				ask();
			}
			else 
			{
				counter++;
				ifWrong();
			}
		}
		
		
		if ( cho == 2 )
		{
			if ( answer == Sub )
			{
				incaseright( radd.nextInt(5));
				NumofCorrect++;
				counter++;
				ask();
			}
			else 
			{
				counter++;
				ifWrong();
			}
		}
		
		if ( cho == 3 )
		{
			if ( answer == Add )
			{
				incaseright( radd.nextInt(5));
				NumofCorrect++;
				counter++;
				ask();
			}
			else 
			{
				counter++;
				ifWrong();
			}
		}
		
	}
}

and here is the main method

Code:

public class QuizTest 
{
	public static void main( String args[])
	{
		 Quiz Try = new Quiz();
		 Try.Chooselevel();
		 Try.ask();
		 
		
	}

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-30-2007, 03:36 PM
A.N.H A.N.H is offline
Newbie
 
Join Date: Apr 2007
Posts: 8
Rep Power: 0
A.N.H is on a distinguished road
Cool

k i found out that it still need some tweaking, after a month or so after i learn how to program using arrays and other stuff i'll do some modifications and post it again in this website, just to c how much i'll improve in a month..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best program for SQL database manipulation Rhadamanthys Database & Database Programming 3 07-02-2007 03:32 PM
How do I Program another Program? ! bosco General Programming 1 06-15-2007 12:15 PM
Need help w/ word count program (ASAP) siren C and C++ 1 04-23-2007 09:14 AM
How to modify a program written in .NET 2.0? jackyjack C# Programming 7 03-27-2007 01:26 PM


All times are GMT -5. The time now is 12:09 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads