Question

In: Computer Science

How would I make it so that when I run my code it does not ask...

How would I make it so that when I run my code it does not ask for input (not having to enter after the statement and enter 0 for example) after ROXY (Forever ROXY Enterprises) appears? Like it would tell me the second statement right away along with the Roxy phrase. This is in C++.

My code:

#include /
#include
using std::endl;

int main()
{
   void readAndConvert();

   unsigned int stockSymbol;
   unsigned int confNum;

   std::cout << "ROXY (Forever ROXY Enterprises)" << endl;
   std::cin >> stockSymbol;
  
   std::cout << "[htrewa] 5000" << endl;
   std::cin >> confNum;
  

   return 0;
}

Solutions

Expert Solution

To do so you have to remove the cin statement and if it is necessary to get those value you have to assign it during its declaration.The "cin>>" statement tells the compiler to read the value from the user so after entering the value the user need to press enter.

Like this,

#include<iostream>

using std::endl;

int main()
{
void readAndConvert();

std::string stockSymbol="[htrewa]";
unsigned int confNum=5000;

std::cout << "ROXY (Forever ROXY Enterprises) " << stockSymbol<<" "<<confNum<<endl;
  

return 0;
}

This is one way of doing that here I assigned the values to be printed next in the variable stockSymbol and confNum.

Other way is,

#include<iostream>

using std::endl;

int main()
{
void readAndConvert();

std::cout << "ROXY (Forever ROXY Enterprises) " <<"[htrewa] 5000"<<endl;

return 0;
}

Here,it is printed directly.

other way is,

#include<iostream>

using std::endl;

int main()
{
void readAndConvert();

std::string stockSymbol;
unsigned int confNum;
std::cin >> stockSymbol;
std::cin >> confNum;
std::cout << "ROXY (Forever ROXY Enterprises) " <<"[htrewa] 5000"<<endl;
    return 0;
}

Here the user inputs the value brfore printing and just prints the line as such.

other way,

#include<iostream>

using std::endl;

int main()
{
void readAndConvert();

std::string stockSymbol;
unsigned int confNum;
std::cin >> stockSymbol;
std::cin >> confNum;
std::cout << "ROXY (Forever ROXY Enterprises) " <<stockSymbol<<" "<<confNum<<" [htrewa] 5000"<<endl;

return 0;
}

here the value user inputs is printed between the line


Related Solutions

Below is my source code for file merging. when i run the code my merged file...
Below is my source code for file merging. when i run the code my merged file is blank and it never shows merging complete prompt. i dont see any errors or why my code would be causing this. i saved both files with male names and female names in the same location my source code is in as a rtf #include #include #include using namespace std; int main() { ifstream inFile1; ifstream inFile2; ofstream outFile1; int mClientNumber, fClientNumber; string mClientName;...
Here is my fibonacci code using pthreads. When I run the code, I am asked for...
Here is my fibonacci code using pthreads. When I run the code, I am asked for a number; however, when I enter in a number, I get my error message of "invalid character." ALSO, if I enter "55" as a number, my code automatically terminates to 0. I copied my code below. PLEASE HELP WITH THE ERROR!!! #include #include #include #include #include int shared_data[10000]; void *fibonacci_thread(void* params); void parent(int* numbers); int main() {    int numbers = 0; //user input....
The code following is what I have so far. It does not meet my requirements. My...
The code following is what I have so far. It does not meet my requirements. My problem is that while this program runs, it doesn't let the user execute the functions of addBook, isInList or compareLists to add, check, or compare. Please assist in correcting this issue. Thank you! Write a C++ program to implement a singly linked list of books. The book details should include the following: title, author, and ISBN. The program should include the following functions: addBook:...
hello! So I have this CIS assignment lab but when I try to make the code...
hello! So I have this CIS assignment lab but when I try to make the code I don't really know where to start from. My professor is very hard and he likes to see the outcomes as they are shown in the problem. Please help me! Write a program that can be used as a math helper for an elementary student. The program should display two random integer numbers that are to be added, such as:     247 + 129...
JAVA: How do I fix the last "if" statement in my code so that outputs the...
JAVA: How do I fix the last "if" statement in my code so that outputs the SECOND HIGHEST/MAXIMUM GPA out of the given classes? public class app { private static Object minStudent; private static Object maxStudent; public static void main(String args[ ]) { student st1 = new student("Rebecca", "Collins", 22, 3.3); student st2 = new student("Alex", "White", 19, 2.8); student st3 = new student("Jordan", "Anderson", 22, 3.1); student[] studentArray; studentArray = new student[3]; studentArray[0] = st1; studentArray[1] = st2; studentArray[2]...
Below is my code in C#, When I run it, the output shows System.32[], Can you...
Below is my code in C#, When I run it, the output shows System.32[], Can you please check and let me know what is the problem in the code. class Program { static void Main(string[] args) { int number=12; Console.WriteLine(FizzArray(number)); } public static int[] FizzArray(int number) { int[] array = new int[number]; for (int i = 1; i < number; i++) array[i] = i; return array; }
LED headlights on cars seem to becoming increasingly popular, so I thought I would make my...
LED headlights on cars seem to becoming increasingly popular, so I thought I would make my problem about that. I believe that the proportion of car owners who have LED headlights is higher than the proportion of car owners to use regular non-LED headlights now, (according to data from 2019) versus in 2010. During two independent surveys, one survey noted that 355 out of 600 car owners had LED headlights in 2020, while in 2010, 250 out of 600 car...
c++ I have my code mostly finished but when printing it is printing incorrectly so 62345...
c++ I have my code mostly finished but when printing it is printing incorrectly so 62345 should == |0|0|0|0|0|0|0|0|6|2|3|4|5| but it is printing as == 5|4|3|2|6|0|0|0|0|0|0 is it with my bigint::bigint(const char c[]) or the output operator<< and with the output should i have something like a while loop to check for leading zeros and print them before any addition. ----------------------------------------------------------------------------------------------------------------------- bigint.hpp; #ifndef BIGINT_HPP #define BIGINT_HPP const int CAPACITY = 400; class bigint { public: bigint(); //default constructor bigint(int); bigint(const...
When does a monopolist make a short-run economic profit? When does it make short-run economic loss,...
When does a monopolist make a short-run economic profit? When does it make short-run economic loss, but continue production? When does it shut down?
I am trying to make a new code that uses functions to make it. My functions...
I am trying to make a new code that uses functions to make it. My functions are below the code. <?php */ $input; $TenBills = 1000; $FiveBills = 500; $OneBills = 100; $Quarters = 25; $Dimes = 10; $Nickels = 5; $Pennies = 1; $YourChange = 0; $input = readline("Hello, please enter your amount of cents:\n"); if(ctype_digit($input)) { $dollars =(int)($input/100); $cents = $input%100;    $input >= $TenBills; $YourChange = (int)($input/$TenBills); $input -= $TenBills * $YourChange; print "Change for $dollars dollars...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT