Skip to main content

Java Projects

How to Make Basic Java programs:




Java is one of the best programming language to make GUI and many other departmental software for making computer handling software . Through java programming you can make games , calculators , ticket Machine and related software because it deals with some wide range of built in functions which every programming language do exist..







Here below is the Code through which you can easily make some basic four programs :


Even or Odd :


import java.util.Scanner;
public class EvenorOdd
{
 public static void main(String Args[])
 {
  int x;
  System.out.println("Enter the number");
  Scanner input = new Scanner(System.in);
  x=input.nextInt();
  
  if(x % 2 ==0)
   System.out.println("The number is even");
  else
   System.out.println("The number is odd");
 }
}



Radius :


import java.util.Scanner;
public class Radius {
 public static void main(String[] args) {
  Scanner scn= new Scanner(System.in);
  float rad;
  System.out.print("Please Enter Radius of a Circle: ");
  rad = scn.nextFloat();
  
  float pi = (float) Math.PI;
  float diam = 2*rad;
  float cir = 2*pi*rad;
  float area = pi*(rad*rad);
  
  System.out.printf("A Circle of Radius %s has: Diameter: %s Circumference: %s Area: %s ", rad, diam, cir, area); 
 }
}



Maximum and Minimum value :
import java.util.Scanner;

public class MaxMin
{
 public static void main(String arg[])
 {
  Scanner cp = new Scanner (System.in);
  
  int inputVal;
  int max = 0;
  int min = 0;

  for(int i=1; i<=5;i++)
  {
   System.out.println(String.format("Enter Value #%s: ", String.valueOf(i)));
   inputVal = cp.nextInt();
   if(i==1)
   {
    min = inputVal;
    max = inputVal;
   }
   if(inputVal > max) {
    max = inputVal;
   }
   if(inputVal < min)
   {
    min = inputVal;
   }
  }
  System.out.println(String.format("Max Value is %s.", max));
  System.out.println(String.format("Min Value is %s.", min));
 }
}


Spacing between digits :
import java.util.Scanner;

public class Spacing{
 
 public static void main(String[] args) {
  Scanner scn= new Scanner(System.in);
  
  int i;
  int maxminAllowed= 5;
  
  System.out.print("Enter 5 Digits: ");
  i = scn.nextInt();
   
  String s = String.valueOf(i);
  int charCount = s.length();
  
  if(charCount == maxminAllowed)
  {
   char[] charss  = s.toCharArray();
   System.out.printf("%s \t %s \t %s \t %s \t %s",charss[0],charss[1],charss[2],charss[3],charss[4]);
  }else if(charCount > maxminAllowed){
   System.out.printf("You can not enter Numbers Greater than %s", maxminAllowed);
   System.out.println("");
   main(args);
  }else {
   System.out.printf("You can not enter Numbers Less than %s", maxminAllowed);
   System.out.println("");
   main(args);
  }
 }
}

    


Keep Sharing !

Comments

Popular posts from this blog

a speculative study of bscs

BSCS STUDENTS AND A CONTEMPORARY FIELD: A SPECULATIVE STUDY TABLE OF CONTENTS EXECUTIVE SUMMARY……………………………………………………………………….4 HISTORY…………………………………………………………………………………………5-6 MODERN TRENDS………………………………………………………………………………7-8 INTRODUCTION…………………………………………………………………………………8 PROCEDURES……………………………………………………………………………………8 METHADOLOGY--------------------------------------------------------------------------------------------9 THEORY OF COMPUTER SCIENCE--------------------------------------------------------------------9 THEORY OF COMPUTATION----------------------------------------------------------------------------10 ALGORITHAM & DATA STRUCTURE-----------------------------------------------------------------10 PROGRAMMING LANGUAGE THEORY---------------------------------------------------------------10 FINDINGS…………………………………………………………………………………………11-14 ANALYSIS………………………………………………………………………………………..15 RECOMMENDATIONS………………………………………………………………………….15 CONCLU...

Technology

Virtual Reality The Next Upcoming Domain in Pakistan is VIRTUAL REALITY and people are making themselves obsessed with it because it takes your imagination to what you are seeing through VR gadget as we know the technology is going to boom in Pakistan through last few years.

Cricket Match

Finally International Cricket again hit the Grounds of Pakistan  Now in Pakistan the Best thing is to about the start of International cricket. Finally the cricket hits the Ground of Pakistan with this phase of  WORLD IX vs PAKISTAN. The schedule is for three days continuous 12 , 13 , 14 September 2017. The all matches will be play in Gaddafi Stadium Lahore , as a FINAL of PSL 02 was also held there.The recent picture is as shown below from Lahore Stadium Cricket is one of the most favourite game of Pakistani's and we love cricket more than our National game because all we like to say that         ↪ "YAR CRICKET LOVE HAI''  We Pakistani's consider to be the most craziest fan's of CRICKET. As we are also moving towards PSL 03 and all the matches are probably be going to Play in Pakistan. The more is coming to pakistan with the passage of time we are moving forward to Meet the International Cricket Standards. Wish All the Be...