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

  • Home
  • SEARCH
  • 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 8700411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:09:46+00:00 2026-06-13T02:09:46+00:00

The issue here is the conditionals inside the for loop are not being entered

  • 0

The issue here is the conditionals inside the for loop are not being entered for some reason. Namely if (samp==1){Since all characters should be 0 or 1 one of these two should be entered at all times instead neither of them is being entered and I am not sure what is going on. It should be a simple character comparison. Also I have tested it to see that the ‘samp’variable is correctly sampling the bit sequence one character at a time.

Could really use some help here. I am sure its mind numbingly simple.

//This method will take in a binary bit sequence which should be set up correctly from above
    //Then it should print the Unipolar encoding of the waveform
    public static void Unipolar(String s){
        String code ="";
        char samp='9';
        char[] charArray = s.toCharArray();  //turn the input bit sequence into a char array for simplicity

        String topline="";     //the method I chose was to keep a consistent 3 strings to draw the output
        String midline="";
        String botline="";



        for (int i = 0; i < s.length(); i++) {
        samp = charArray[i];
        System.out.println(samp);
            //depending on if the current character is a 1 or a 0 a differnt pattern will be added to the 
            //string to be outputted
            if (samp==1){
                topline+="*****"; 
                midline+="*    ";
                botline+="*    ";
            }
            if (samp==0){
                topline+="     ";
                midline+="     ";
                botline+="*****";
            }
        }
        System.out.println(topline);
        System.out.println(midline);
        System.out.println(botline);
    }
  • 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-13T02:09:47+00:00Added an answer on June 13, 2026 at 2:09 am

    You should use the character values when comparing chars:

    if (samp == '1') {
       ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue here, I am trying to get all the titles from
I have investigated this issue now since some time and it seem obvious to
My issue here is quite simple : i'm trying to use the jQuery validate
Im having a weird issue here. Its probably just something stupid but I dont
I am facing a issue here in reading the values set by a stored
I have a curious issue here In my ejbCreate() method from where i insert
I've a small issue here. I am using an if statement with UIAlertView and
Having an issue here that I have tried everything I can think of but
Im having a weird issue here; The following .htaccess works but now (after changing
I'm facing an issue here. For Facebook debugging reasons, I made a host entry

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.