d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Ignore This Its For A Friend
Add Reply New Topic New Poll
Member
Posts: 3,085
Joined: Jun 27 2007
Gold: 68,222.00
Oct 27 2012 01:14am

import java.util.*;
import java.text.*;
public class AssignmentNo3
{
static void main (String [] args)
{
//First Digit Variables
int firstD;

//Third Digit Variables lp=licenseplate
String lp;
String abc;
String lpNumS;
String holder;
int letter;
int pos3;
int lpNum;
int thirdD;
char letters;

//Eighth Digit Variables
String dateH;
String month;
String year;
int pos8;
int yNum1;
int yNum2;
int eighthD;

//Last Digit Variables
int lastD;
int sixthD;

//Name changing
String name;
String firstN;
String lastN;
int posN;

//Universal Variables DF == digit final
String regNo;
String firstDF;
String thirdDF;
String eighthDF;
String lastDF;
String secondDF;
String fFDF; //fourth and fifth digit finals
String sixthDF;
String nTEDF; //ninth tenth and eleventh digit finals
String seventhDF;

//Incializing instances of classes / creating objects
Scanner kb = new Scanner(System.in);
Random random = new Random();
Date date = new Date();
SimpleDateFormat dateft = new SimpleDateFormat ("MMM yyyy");
Calendar dateR = Calendar.getInstance();

// Getting user imput
System.out.println ("Enter license plate number (LLL-DDD): ");
lp = kb.nextLine();
System.out.println ("Enter owner's name (fistname lastname: ");
name = kb.nextLine();

//Getting first Digit
firstD = random.nextInt(7)+ 3;

//Getting Third Digit
abc = " ABCDEFGHIJKLMNOPQRSTUVWXYZ";
lp = lp.toUpperCase();
letters = lp.charAt(1);
letter = abc.indexOf(letters);
pos3 = lp.indexOf("-");
holder = lp.substring(pos3+1);
lpNum = Integer.parseInt(holder);
lpNum = lpNum + letter;
lpNumS = Integer.toString(lpNum);
holder = lpNumS.substring(1,2);
thirdD = Integer.parseInt(holder);

//Getting Eighth digit
dateH = dateft.format(date);
pos8 = dateH.indexOf(" ");
month = dateH.substring(0, pos8);
year = dateH.substring(pos8 +1);
month = month.toUpperCase();
yNum1 = Integer.parseInt(year.substring(2,3));
yNum2 = Integer.parseInt(year.substring(3));
eighthD = (yNum1 + yNum2) % 10;

//Getting Last Digit
sixthD = random.nextInt(10);
lastD = (eighthD + thirdD + sixthD) % 10;

//Coverting Digits to strings and creating remaining digits
firstDF = Integer.toString(firstD);
secondDF = Integer.toString(random.nextInt(10));
thirdDF = Integer.toString(thirdD);
fFDF = Integer.toString(random.nextInt(90)+10);
sixthDF = Integer.toString(sixthD);
seventhDF = Integer.toString(random.nextInt(10));
eighthDF = Integer.toString(eighthD);
nTEDF = Integer.toString(random.nextInt(900)+100);
lastDF = Integer.toString(lastD);

//Changing Name
posN = name.indexOf(" ");
firstN = name.substring(0, posN);
lastN = name.substring(posN+1);
lastN = lastN + ",";
lastN = lastN.substring(0,1).toUpperCase()+lastN.substring(1).toLowerCase();
firstN = firstN.substring(0,1).toUpperCase()+firstN.substring(1).toLowerCase();
name = lastN + " " + firstN;

//Creating the registration number and final touches
regNo = firstDF + secondDF + thirdDF + fFDF + sixthDF + seventhDF + eighthDF + nTEDF + lastDF;
Format renFor = new SimpleDateFormat("MMM yyyy");
dateR.setTime(new Date());
dateR.add(Calendar.YEAR,1);

//Outputting
System.out.println("Imformation for printed registration form:");
System.out.println("");
System.out.println("Registration No. "+regNo);
System.out.println("License Plate No. "+lp);
System.out.println("Owner "+name);
System.out.println("Renewal Month "+renFor.format(dateR.getTime()));

}
}
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Oct 27 2012 01:52am
pastebin.com

and your code looks terrible.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Oct 27 2012 01:56am
cheating on tests 101

IM NOT ON GOOGLE PROFESSOR ITS OKAY
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 27 2012 01:04pm
Quote (Eep @ Oct 27 2012 03:56am)
cheating on tests 101

IM NOT ON GOOGLE PROFESSOR ITS OKAY


what?
Member
Posts: 644
Joined: Oct 27 2012
Gold: 1,404.00
Oct 27 2012 07:56pm
Quote (irimi @ Oct 27 2012 03:52am)
pastebin.com

and your code looks terrible.


Agreed. Code is really poorly written. If this is for a class, this is definately C+ work at most.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Oct 27 2012 09:09pm
Quote (AbDuCt @ Oct 27 2012 02:04pm)
what?


lol. In my 1250 class my professor would let us browse websites if we needed to.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 27 2012 09:18pm
Quote (Eep @ Oct 27 2012 11:09pm)
lol. In my 1250 class my professor would let us browse websites if we needed to.


back in high school, i used to create a free website and add a bunch of stuff to it. then i could cite myself as a source for my essays and pretend i was some knowledgeable pro. then i discovered wikipedia.
Member
Posts: 3,064
Joined: Mar 30 2003
Gold: 5,095.00
Oct 31 2012 09:03am
Quote (carteblanche @ Oct 27 2012 10:18pm)
back in high school, i used to create a free website and add a bunch of stuff to it. then i could cite myself as a source for my essays and pretend i was some knowledgeable pro. then i discovered wikipedia.



That's hilarious... I did the same exact thing... I thought I was totally awesome and clever for it too... Apparently, one is never as original as they think they are.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Oct 31 2012 09:58am
Quote (carteblanche @ Oct 27 2012 10:18pm)
back in high school, i used to create a free website and add a bunch of stuff to it. then i could cite myself as a source for my essays and pretend i was some knowledgeable pro. then i discovered wikipedia.


Brilliant. I never put much effort into my homestead and geocities pages.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll