Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8964525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:36:41+00:00 2026-06-15T16:36:41+00:00

Alright, so here is my code: import java.util.Scanner; public class CarRental { public static

  • 0

Alright, so here is my code:

import java.util.Scanner;

public class CarRental {

    public static String model;
    public static int letternum;
    public static String plate;
    public static String letter;
    public static int total;              
    public static String alphabet = "abcdefghijklmnopqrstuvwxyz";

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        //System.out.println("Car Model:");
        //model = input.nextLine();
        System.out.println("License Plate: ");
        plate = input.nextLine();

        char one = plate.charAt(0);
        char two = plate.charAt(1);
        char three = plate.charAt(2);
        total = one + two + three;
        letternum = total % 24;

        char letter = alphabet.charAt(letternum);

        System.out.println("" + letter + total);

    }
}

What is going on is this, I’m trying to make it take my license plate input and take the characters at the places for 0, 1, and 2. Which in a license plate would be the three letters. Then, i’m trying to take their ASCII Values, add them all together and set them to the int “total”. Then to find a Letter that is supposed to be in front of the total value, I find the remainder of the total by using % 6. Then it will take that value, and whatever number it is, say it is 4, it will take the 4th letter in the string “alphabet” and set that to a the char “letter”. Then what it should do is print out the letter followed by the totals of the ASCII Value.

Here is an example of what is my input with expected outcome, followed by its ACTUAL outcome.

License Plate: CPR 607

Output: E836

My output with the exact same license plate is:

License Plate: CPR 607

n229

I’m not sure what I’m doing wrong, but my best clue is that the fact that it is a char, it is treating it like its ASCII Value, rather than its String value(which i’m actually trying to get)

If anyone could suggest some tips, it would be a great help. Not necessarily code I can just leech off of, but how I should go about doing this the right way!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:36:42+00:00Added an answer on June 15, 2026 at 4:36 pm

    You want to take the second part of the string (with the three numbers) and add it to your total. You can take that value with:

    Integer.parseInt(plate.split(” “)[1])

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, here is my code for the O(n): import java.util.*; public class BigO{ public
Alright so here's my current code: import System.IO import System.Environment import System.Directory main =
Alright...I am here looking for some bread crumbs. This is my code: using System;
Alright I'm totally baffled. Here's my code: if ($password == $correct_password[0] && !isset($_COOKIE['user'])) {
Alright, here I am again trying to write code from scratch and I can't
Alright so here is the question. I have a user class which contains a
Alright here's the code: //in another file void **ptr; ptr = kmalloc(sizeof(void *) *
alright, im looking at a code here and the idea is difficult to understand.
Here is my code. #include<stdlib.h> #include<stdio.h> int main(int argc,char** argv) { char a; a=9;
I have written this piece of code here and I have linked it alright

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.