I am having trouble making my program output correctly on my 2nd while loop

+2 Giorgio M · September 19, 2015
I am just having issues with this program big time. I have been working on it for 6 days and still no cigar. What's going on is I am trying to do the juggler sequence and I have the calculations correct, the issue I am now having is every time I do the calculations the same number keeps printing and I am having trouble making it output all the numbers on 1 line. If anyone can help that'll be great. Thank you!

This is how the output SHOULD look like but I can't get it.
http://imgur.com/MX6CKhD



#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>

using std::cout;
using std::cin;
using std::endl;
using std::setw;


/*
 * 
 */
int main(){
    long user_int = 0;
    long end_int = 0;
    long counter = 0;
    long int_per_line = 0;
    long user_ans = 0;
    
    cout << "Enter two separate numbers, check from low to high " << endl;
    cout << "Input 1st integer: ";
    cin >> user_int;
    cout << "Input 2nd integer: ";
    cin >> end_int;
    
    counter = user_int - 1;
    
    
    long end_start = end_int - user_int;
    
    
    cout << "Do you want to see each sequence (1=yes/0=no):  ";
    cin >> user_ans;
    
    
    while(user_ans == 1){
        for(long i = 0; i <= end_start; i++){
        
            if(user_int % 2 == 0){
                user_int = pow(user_int, 0.5);
                user_int = floor(user_int);
            }
            
            else{
                user_int = pow(user_int, 1.5);
                user_int = floor(user_int);
            }
      
        
            while ( i <= end_start){
                counter = counter + 1;
                if(user_int != 1){
                    cout << "Juggler sequence of " << counter << " is:" << user_int << endl;
                    i = i + 1;
                }
            }
            
        }
        
        
    cout << "Do you want to see each sequence (1=yes/0=no):  ";
    cin >> user_ans;
    

    
    }
    
    
        return 0;
}


Post a Reply

Replies

- page 2
Oldest  Newest  Rating
+2 Giorgio M · September 19, 2015
Thank you Milan!
+1 Giorgio M · September 19, 2015
Hey Milan, if you don't mind, is it alright if you could delete that pastebin file? Thank you again
+1 Milan Obrenovic · September 19, 2015
i cant, the link will exist forever. i can only edit my comment to delete the link there, if it helps?
+1 Giorgio M · September 19, 2015
That helps, Thanks Milan!
+1 Milan Obrenovic · September 19, 2015
ahh okay, i understand now (accidentally deleted my above question, sorry).
+1 Giorgio M · September 19, 2015
Can you help me with my output? I ran out of ideas
+1 Milan Obrenovic · September 19, 2015
yes i'm trying now
  • 1
  • 2

C++

106,974 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator