Posts

Showing posts from 2016

simple hangman code in java

A very simple hangman code in java -------------------------------------------------------------------------------------------------------------------------- package assignment; import java.util.*; class game { String word[]={"appreciate","arithmetic","artificial","earthquake","economical","elasticity", "population","positively","screenplay","toothpaste"}; String mword2; String t; int temp; int random() { Random rn = new Random(); //to generate random no. between 1-9 int rand = rn.nextInt(9)+1; return rand; } String chooseword()  //to choose a random word {   String mword; int r=random(); mword=word[r]; return mword; } String modword()  // to put "_" in word {  int t2; t=chooseword(); String st=t; for(int i=0;i<5;i++) { t2=random();    st=change(t2,st); } return st; } String change(int t2,Str...