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:...
I have a problem with my code. It does not run. Please can someone check the...
I have a problem with my code. It does not run. Please can someone check the code and tell me where I went wrong? This is the question: Program Specification: Write a C program that takes the length and width of a rectangular yard, and the length and width of a rectangular house (that must be completely contained in the yard specified) as input values. Assuming that the yard has grass growing every where that the house is not covering,...
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...
This code needs to run a working Reverse Polish Calculator, but when I input my commands...
This code needs to run a working Reverse Polish Calculator, but when I input my commands it only pops my inputs never push them. So my answer is always zero. Here is my code. #include <stdio.h> #include <stdlib.h> #include <stdbool.h> struct Node { int element; struct Node *next; }; //Global variable struct Node *top = NULL; void push(int ele) { struct Node *newNode; newNode = (struct Node *) malloc(sizeof(struct Node)); newNode->element = ele; newNode->next = top; top = newNode; }...
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]...
what is the solution of this code? Also how would I run it in python to...
what is the solution of this code? Also how would I run it in python to check? q = Queue() q.enqueue(10) q.enqueue(12) q.enqueue(15) for i in range(len(q)): → if len(q) % 2 == 0: → → q.enqueue(q.dequeue()) → else: → → q.dequeue() print(q)
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT