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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:08:30+00:00 2026-06-13T09:08:30+00:00

The keypad is broken so the input numbers 1, 4, and 7 aren’t working.

  • 0

The keypad is broken so the input numbers 1, 4, and 7 aren’t working. In turn the computer outputs the next lowest and next highest number where 1, 4, and 7 are none of the digits.

My goal is to check out the digits and output true using a boolean function and then output the next highest number and next lowest number. I’m pretty sure I did most of what I need to do, but it isn’t working out.
I have inputted the number 444, and the results that came out were 443, and 445.
Thank you for your help.

 #include <iostream>
 #include <conio.h>
 #include <cmath>

using namespace std;

bool containDigit(int number, int digit);

int main()
{
    int number, digit, lowNum, highNum;

cout<<"Enter a number between 1 and 999 for the oven temperature: ";
cin>>number;

//1st digit
digit = number / 100;
containDigit(number, digit);
if (containDigit(number, digit) == true)
{
    number = number - 100;
}

//2nd digit
digit = (number / 10) % 10;
containDigit(number, digit);
if (containDigit(number, digit) == true)
{
    number = number - 10;
}

//3rd Digit
digit = number % 10;
containDigit(number, digit);
if (containDigit(number, digit) == true)
{
    number = number - 1;
}

cout<<number<<endl;


getche();
return 0;

}

bool containDigit(int number, int digit)
{
    if ((digit == 1) || (digit == 4) || (digit == 7))
    {
        return true;
    }
    else
    {
        return 0;
    }
}
  • 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-13T09:08:31+00:00Added an answer on June 13, 2026 at 9:08 am

    Since this looks like homework, I will refrain from doing it for you and give you these hints:

    It looks like you’re not really clear on what “1st digit” is. Is it the first one from the left (hundreds) or the right (ones)? Look at your code and tell yourself how each portion of it would answer my question.

    Is it ever possible for lowNum or highNum to have more than one digit different than number with your code as it is? How? Where are lowNum and highNum changed, and how?

    Also, to expand on what @Al Kepp has said: When you have a function like that, try to test it with some very simple inputs rather than straight out assuming it works. This is called (or is similar to) “unit testing”, which dictates that you divide your program into simple, independent units and test them separately. A simple call like containDigit(999, 4) returning true would’ve rang warning bells.

    And speaking of warnings, always, always compile with as many of them as you can stand. (e.g. -Wall for gcc) Doing such might’ve warned you of the fact that you’re not using the parameter number inside containDigit at all.

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

Sidebar

Related Questions

I am working on a keypad on java that will be used to input
I have an array of JButtons which form a keypad interface. After six numbers
I am creating and putting a custom number bar on top of regular keypad.
I am working on a Kiosk Touch Screen application and using the JQuery.keypad plugin
I'm using Javascript, I need to get the keypad numbers. For what ever reason,
I am building an application where I want to show only numbers keypad i.e
I've seen lots and lots of questions about selecting the best input Type keypad
I have an app im working on. The main view controller has a keypad
Is it possible to press keypad programmatically so that number for the key pressed
How would you go about mimicing the iPhones keypad input. So that when you

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.