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 7600877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:01:20+00:00 2026-05-30T23:01:20+00:00

Since I’m rather new to Java, I am not familiar with all the ways

  • 0

Since I’m rather new to Java, I am not familiar with all the ways of handling this type of an assignment. I studied C and C# throughout my high school but I just started Java few days ago.

The task goes like this:

Write a program that reads 10 single-digit integers and displays a string consisting
of 10 characters using the coding scheme:
Digit Corresponding Character
0-a
1-b
2-c
… …
9-j
For example, if input consists of the 10 digits 1 8 6 1 0 3 1 8 5 5, the application
responds with “bigbadbiff.”

Since I moved from C and C# at first I had trouble allowing user to input the integers of the array, but I got that figured out. And this is what I got so far.

import java.util.*;

public class UnsualCoding
{
    public static void main (String[] args)
    {
        Scanner util = new Scanner(System.in);
        int[] x = new int[5];
        int counter = 0;

        for(int i = 0; i < x.length && util.hasNextInt(); i++)
        {
            x[i] = util.nextInt();
            counter++;
        }

        System.out.println("\n\n");
        System.out.println("Our array looks like");

        for(int i = 0; i < x.length; i++)
        {
            System.out.println(x[i]);
        }

        System.out.println("\n\n");

    }

}

Should I create a list, copy the content from an array to it and do the change or should I approach this problem differently? Can I convert the array to string? Also how can I bind/assign the characters to the given numbers?

Thank you.

  • 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-05-30T23:01:21+00:00Added an answer on May 30, 2026 at 11:01 pm

    Since there are only 10 possibilities, you could put the characters that you want to encode into an array, and use the int inputs as the index to that array.

    char[] y = new char[]{'a','b','c','d','e','f','g','h','i','j'};
    

    Then the only part of your code that would change would be where you print it out :

    System.out.println(y[x[i]]);
    

    Though you may want to change your x array to be of arbitrary length as well.

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

Sidebar

Related Questions

Since java does not support multiple inheritance I have a problem getting this to
Since I started this new webshop for a friend to launch, which still in
Since I'm using Java 1.4.2, this means that I cannot use Java's implementation of
Since ColdFusion is itself Java-based, I would imagine it's not too much of a
Since both a Table Scan and a Clustered Index Scan essentially scan all records
Since Rails is not multithreaded (yet), it seems like a threaded web framework would
Since the release of Adobe AIR I am wondering why Java Web Start has
Since hist() of the base R does not report percentages (and the freq=FALSE) does
Since i'm not strong in asp.net, probably my question will sound silly. I've got
Since yesterday suddenly my Eclipse does not work anymore. The error is Failed to

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.