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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:19:25+00:00 2026-06-12T11:19:25+00:00

Hello I’m having issues on my intro to Computer Science Lab Work: CharacterLine.java: Write

  • 0

Hello I’m having issues on my intro to Computer Science Lab Work:

CharacterLine.java: Write a program that prints a line of characters. Prompt the user to enter a character and then ask for a number. If the number is lies than 1 or greater than 80, tell the user then to exit the program. Use a while Loop to print out the character as many times as the number read in.
Example:
Please enter a character: &
Please enter a number: 15
Your line: &&&&&&&&&&&&&&&

Here is my code:

import java.util.Scanner;

public class CharacterLine

{
    public static void main(String[] args)
    {

        Scanner kb = new Scanner (System.in);
        int number;
        System.out.print("Please enter a character: ");
        String character = kb.next();
        int charact = character.length();

        System.out.print("Please enter a number: ");
        number = kb.nextInt();

        while ( number <= 80 && number >= 1 ){

            if ( number <= 80 && number >= 1 ) {
                int bills = (charact * number);
                System.out.println("Your line: " + charact++);
            }
            else {
                System.out.println("error.");
            }
            System.out.println();
            System.out.print("Please enter a number: ");
            number = kb.nextInt();
        }
        if ( number > 80 ){
            System.out.println("That number is too large");
        }
        else if ( number < 1 ){
            System.out.println("That number is too small");
        }
        else{
            System.out.println("error");
        }
    }
}

I am having issues in knowing how I can multiply the number that the user inputted and make the output the number times the one letter that the user inputted.

Thanks,
William

  • 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-12T11:19:27+00:00Added an answer on June 12, 2026 at 11:19 am

    You can use loop to iterate for given number of times.. and print the character..

    if ( number <= 80 && number >= 1 ) {
    
       char myChar = '*';
    
       // This while loop will run 15 times if value of number is 15..
       while(number > 0) {
            System.out.println(myChar);
            number--;   // Decrement the value of `number` by 1.
       }
    }
    

    The above while loop says:

    While the value of number is greater than 0, execute the loop, and
    print the statement inside it.. After printing, decrement the value of
    number by 1, and check the condition once again… Continue this
    process while number > 0

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

Sidebar

Related Questions

Hello guys I need to pass a string array over to a setter that
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler
Hello I want to know how to highlight all Words that is inputted in
Hello does any one know that setting I need to ON for connect to
Hello there I am new to php and want to learn to write reusable
Hello i'm having some trouble in displaying multiple pushpins on maps. So far i've
Hello all and thanks for the attention! I have a problem that must both
Hello everyone I have converted a project in C# to F# that paints the
hello I build application with google maps api , the apk work fine till
Hello I am working with a simulator that uses rcS scripts to boot, this

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.