Answered step by step
Verified Expert Solution
Question
1 Approved Answer
problem 4 Solve programming excercise 4.25 in page 157 of the textbook (page 156 in the 10th edition) BUT MODIFY IT so that a vehicle's
problem 4 Solve programming excercise 4.25 in page 157 of the textbook (page 156 in the 10th edition) BUT MODIFY IT so that a vehicle's number plate consits of 1 uppercase letter, 2 lowercase letters, followed by 6 digits.
I currently have a code but I can't get 1 uppercase 2 lowercase. MY CODE Already has the 6 digit. I need help with lines 15-21. They print out as numbers instead of letters
9public class PlateNumber 10 public static void main (String[] args) i 12 13 14 15 16 17 18 19 20 21 String plateNumber: int numberPart, letterPartl, letterPart2, letterPart3: numbe r Part = (int) (Math. random ()*1000000) ; //a + Math.randomb 65-91 Returns a random number between a and a b, excluding a +b. 65 26 letterPart1 = (int) (65 + (Math. random ( )*26)); String char1 = String . valueOf (Character. toChars (letterPart1)); letterPart2 = (char) (int) (97 + (Math. random ( )*26) ) ; String char2 = String . valueOf (Character. toChars (letterPart2)); letterPart3 = (char) (int) (97 + (Math. random ( )*26) ) ; String char3 = String. valueOf (Character. toChars (letterPart3)); 23 24 25 26 27 28 29 //char //char //char Uppe r letter lowe r letter! lowe r letter (char) ((int ) Math . random ( )*26+65); //generates a uppercase letter - (char) ((int ) Math.random ( )#26+97); //generate a random lowercase letter (char) ((int ) Math. random ( )*26+97); //generates a random lowercase letter int numbers = (int) (Math. random ( )*10000); String snumbers String . fora t ("%04d", numbers); System.out.println ("The plate number is " tletterPartltletterPart2tletterPart3+snumbers) 31 32
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started