+ Reply to Thread
Results 1 to 2 of 2

Thread: The latest program i wrote!!

  1. #1
    Newbie A.N.H is an unknown quantity at this point
    Join Date
    Apr 2007
    Posts
    8

    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();
    		 
    		
    	}
    
    }

  2. #2
    Newbie A.N.H is an unknown quantity at this point
    Join Date
    Apr 2007
    Posts
    8

    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..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Need help w/ word count program (ASAP)
    By siren in forum C and C++
    Replies: 3
    Last Post: 09-11-2009, 07:17 AM
  2. Best program for SQL database manipulation
    By Rhadamanthys in forum Database & Database Programming
    Replies: 3
    Last Post: 07-02-2007, 02:32 PM
  3. How do I Program another Program? !
    By bosco in forum General Programming
    Replies: 1
    Last Post: 06-15-2007, 11:15 AM
  4. How to modify a program written in .NET 2.0?
    By jackyjack in forum C# Programming
    Replies: 7
    Last Post: 03-27-2007, 12:26 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts