Advertisement
3nriched

Untitled

Sep 10th, 2011
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. import java.util.Scanner;  // Needed for accepting input
  2.  
  3.  public class ProjectOneAndreD
  4.  {
  5.  
  6.    
  7.     public static void main(String[] args)
  8.     {
  9.         String input1;
  10.         char coln = ':';
  11.         int val=0, rad=0, answer=0, check1=0;
  12.            
  13.             Scanner keyboard = new Scanner(System.in);  //creates new scanner class
  14.             do
  15.         {
  16.             System.out.println("****************************************************");
  17.             System.out.println("             This is Project 1. Enjoy!              ");     //title
  18.             System.out.println("****************************************************\n\n");
  19.  
  20.             System.out.println("Enter a number, : and then the radix, followed by the Enter key.");
  21.             System.out.println("INPUT EXAMPLE:  160:2   {ENTER} ");     //example
  22.            
  23.             System.out.print("INPUT:  ");               //prompts user input.
  24.             input1 = keyboard.nextLine();       //assigns input to string input1
  25.  
  26.            
  27.             check1=input1.indexOf(coln);
  28.            
  29.             if(check1==-1)
  30.             {
  31.                 System.out.println("I think you forgot the ':'.");
  32.                
  33.             }
  34.             else
  35.             {
  36.                 System.out.println("found ':'");
  37.            
  38.             }
  39.             }while(check1==-1);
  40.                    
  41.                    
  42.                    
  43.                    
  44.                    
  45.                    
  46.                    
  47.                    
  48.                    
  49.                    
  50.     }
  51.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement