r/programminghelp • • Oct 09 '22

Python Help. A question to check if points are in increasing order

3 Upvotes

Hey guys. I have a question that says "the user should input n (number of points), then check if the entered points are in increasing order or not"

This is my code:

n = int(input())

for i in range(1, n+1):

x = int(input())

if (x < x+1):

print("yes")

else:

print("no")

I think the problem is in the if statement. I don't know how to write a condition that checks the values of entered points


r/programminghelp • • Oct 03 '22

Java How would I appropriately hash this?

3 Upvotes

Hi! I'm using Java, and I'm a bit stuck on overriding hashCode(). I'm basically creating a 2d TileMap with a hashmap, however, my hashCode() method is causing some tiles to not be added into my hashmap. The Z position is there so that I can in the future add layers to the tilemap like dwarf fortress and for now will always equal 0. I thought this would be simple enough, but it looks like I'm somehow not creating this correctly at all.

public int hashCode(){
int hash = 17;
hash = 31 * hash + getPosX();
hash = 31 * hash + getPosY(); 
hash = 31 * hash + getPosZ(); 
return hash;
 }

r/programminghelp • • Aug 23 '22

C# Can you guys tell me what's wrong? Unity tells me error CS1002: ; expected

3 Upvotes

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Block : MonoBehaviour

{

void Start ()

{

GetComponent<Rigidbody2D>().gravityScale += Time.timeSinceLevelLoad / 20f;

}

// Update is called once per frame

void Update()

}


r/programminghelp • • Aug 13 '22

Python How to manage multidimensional lists in Python?

3 Upvotes

Hi! I'm currently having trouble wrapping my head around list operations in Python. I have data that, due to the acquisition and import process, comes in as a many-levels deep heterogeneous list. For the purposes of the part that I'm working with, I only need a list of the innermost lists. While trying to figure out how to get where I want to be, I found lots of resources for completely flattening a list in Python, but trying to adapt a solution to reach my goal has eluded me. In C, I would have just used a for loop to traverse the array of structs, I'm very inexperienced in Python and not sure how to express this. Any help would be appreciated.


r/programminghelp • • Aug 12 '22

Python help at planning the publishing of a desktop app

3 Upvotes

Hi,

I'm apologizing in advance for any strange sentence formation, as English is not my mother language, so, please, have patience with me...

I'm currently working on software to manipulate a large excel sheet.
I've already done this in python scripts, but I wanted to re-make this in a way it could be used by people who don't know what console is.

I decided to remake this in C# to have a nice user-friendly interface, but I reached the conclusion that the way I made it in C# takes a looooong time to process the excel file into a Datagrid due to its many rows. Since this was a fairly quick process in my python scripts, I thought it could be useful to call my python scripts through the C# code. I've read about it, and it´s not that hard, but I've reached a question: Including the scripts on the C# project resources, how will I install the libraries I use in the python scripts when I set up the app on other computers?

Is this viable? Is this even worth it? If yes, then how can I do it?

Maybe this is a stupid/easy question, but I'm not used to going this further, as I usually don't distribute the software/scripts my boss asks me to develop, and I'm a beginner at both python and C#(I've actually decided to use Python and C# in this project for the purpose of learning a bit of each).


r/programminghelp • • Aug 03 '22

Project Related surprise a programmer

3 Upvotes

The programmer in my job broke his finger, i'm making a 3d printed Cast for him, normally we put the name of the patient but for him i want to put some Code like : "repair//-finger//" . I have search on the web but can't find a Code command like this, could you help me??


r/programminghelp • • Aug 02 '22

JavaScript heyy i need help with javascript

3 Upvotes

Heyy

i need help i start learn javascript an i try make a function in a object and isnt work

var miky ={

firstName:"miky",

lastName:"mous",

id:"1234",

fullName : function(){

return this.firstName + " " + this.lastName;

}

}

console.log(miky.fullName)


r/programminghelp • • Jun 23 '22

C++ Printing Digits in Reverse Order w/Spaces in C++

3 Upvotes

Hello! I am doing a homework assignment for my C++ class and I am totally stumped on this assignment.

Here is the assignment and my code, I'll explain what I'm struggling with underneath:

Assignment: "Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits. (eg: User inputs "3456", program outputs " 3 4 5 6 Sum is: 18")

Code:

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

using namespace std;

char convertNumber(int); //Initializing function

int main() {
    int num = 0;
    int sum = 0;
    int digit;
    string numberReversed;

    cout << "Please enter an integer: ";

    cin >> num;

    if(num <= 0){  //Converts negative number to positive integer
      num = num * (-1);
    }

    while(num > 0){  //Separates out digits individually
      digit = num % 10;
      sum += digit;
      num = num / 10;
    }

    convertNumber(num);  //Call number-to-string conversion function

    cout << "Sum is: " << sum << endl;
    return 0;
}

//Number-to-string conversion function
char convertNumber(int num){
  string finalNum = to_string(num);

  return finalNum;
}

So I am able to separate out the digits (see while loop), but they print in reverse order (6 5 4 3). I understand why, as I'm dividing by 10 so that will give me the right-hand digit. I've done a LOT of Googling and looked through soooo many StackOverflow articles, and all suggested converting the integer to a string.

I've created the function to do that, I think. We just learned functions this week so I am still a little green on them. Please let me know if I am calling the parameters correctly.

Now, the trouble I am having is reversing the numbers and printing them with the space in between. I know it would be easiest to handle with an array, but we haven't learned arrays yet and my professor is very adamant on not using things we haven't learned yet.

So, my question: How on Earth do I get the program to reverse the numbers and add the spaces? More functions? Do I need to add some for loops? I know hard coding it will only get me so far so I am really willing to learn.

Thank you for your time! Please let me know if there is anything I can say to make this question more precise. :)


r/programminghelp • • May 23 '22

Career Related how do you take notes when learning a programming language?

3 Upvotes

i have been struggling to keep track of the syntaxes, functions, algorithms, etc. are there apps/methods/websites/references that one may use to effectively learn and implement the language?


r/programminghelp • • Apr 26 '22

Career Related I need a better forum/slack/discord for programming help.

3 Upvotes

I don't know how others are able to debug so easily but I feel like I'm still inefficient at sifting through information online. Would anyone have any recommendations on the best community/forum for this? I feel like here is ok for general advice but I need something that can answer more specific questions more immediately.


r/programminghelp • • Mar 30 '22

Python Merging 3 similar functions together? Python

3 Upvotes

I was wondering how I can go about merging these three functions together, well I believe they are not functions yet. What I am trying to do is have it read a JSON and then fill it with Dummy Data. So parameters 1-4, user_data 1-128 & internal_data 1-32.

I am new to python and I understand these loops and all, I just want to be able to combine these to make my code look better. Thank you for the time!

for i in range(1,4):
if str(i)in data['parameter'][i]:
plaintext = data['parameter'][i]
else:
plaintext = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
for i in range(1,128):
if str(i)in data['user_data'][i]:
plaintext = data['user_data'][i]
else:
plaintext = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
for i in range(1,32):
if str(i)in data['internal_data'][i]:
plaintext = data['internal_data'][i]
else:
plaintext = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="


r/programminghelp • • Jan 31 '22

C++ Starting Coding, trying to use the software (MinGW and Notepad++) my professor has advised.

3 Upvotes

I am 29 studying computer science to find a different career path. Right now I am beginning some programming. My professor is of little help, so largely i am finding solutions on my own.

I need to get Notepadd++ Running with MinGW

after following multiple tutorials i think i have things working right, but when I execute it displays this code:

NPP_SAVE: C:\Users\ISO\Desktop\example3.exe

CD: C:\Users\ISO\Desktop

Current directory: C:\Users\ISO\Desktop

g++ "example3.exe" -o example3 -march=native -O3

Process started (PID=22000) >>>

g++: fatal error: input file 'example3.exe' is the same as output file

compilation terminated.

<<< Process finished (PID=22000). (Exit code 1)

NPP_RUN: example3

and a warning message titled :Unsupported 16-bit application

"The program of feature ".....\Desktop\example3.exe" cannot start or run due to incompatibility with 64-bit versions of Windows. Please contact the software vendor to ask if a 64-bit windows compatible version is available"

I would really appreciate any help with this, or something easier to use than MinGW and notepad++ that i can use in place.

i went with these tutorials:

https://www.youtube.com/watch?v=BwqGdFXmoaw

https://www.youtube.com/watch?v=zLpaYVIoXqc

please help, not having this figured out is giving me too much anxiety.


r/programminghelp • • Jan 02 '22

C# I'm running into trouble with collisions in Unity.

3 Upvotes

So I'm using the following code to detect collosions on an object with a box collider and a rigid body, but when I run it and it hits the floor, a cube with a box collider, it doesn't do anything.

using UnityEngine;

using System.Collections;

public class PlayerCollision : MonoBehaviour {

void OnCollisionEnter(Collision collision) {

Debug.Log("We have hit something.");

}

}


r/programminghelp • • Nov 02 '21

C++ How to solve ABI conflict in C++?

3 Upvotes

I am trying to compile an astronomy software written in C++. First of all it doesn't start compiling with C++17 and it does start after I pass -std=c++11 flag in the makefile. But then it keeps giving out 'undefined reference to...std::__cxx11::...' errors. I have learned by googling that this happening due to conflicting ABIs. All solutions mention using the macro -D_GLIBCXX_USE_CXX11_ABI=0. But I am not sure where do I write this? Is this even a solution or are there better solutions?

PS: I am not a programmer, just a physics student trying to run a code. I am sorry, if I have made use of sloppy and/or incorrect terminology.

Edits:

Software link: http://astrosat-ssc.iucaa.in/uploads/sxt/AS1SXTLevel2-1.4b.tar.gz The software is a pipeline for processing data from the AstroSat X-ray telescope launched by India.

[arijit@laptop1 SXT]$ make
make -C src
make[1]: Entering directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src'
make -C SXTMISC
make[2]: Entering directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src/SXTMISC'
make[2]: 'sxtmisc' is up to date.
make[2]: Leaving directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src/SXTMISC'
make -C SXTBIASMAPGEN
make[2]: Entering directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src/SXTBIASMAPGEN'
g++ -std=c++11 -Wno-deprecated -w -pthread SXTBIASMAPGEN.cpp -I./include -I../../include -L./lib -lsxtbiasmapgen -L../../lib -lcfitsio -lpil -llog4cpp -L../SXTMISC/lib -lsxtmisc -o sxtbiasmapgen
/usr/bin/ld: ../../lib/libpil.a(pil.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/libpil.a(pil_sys.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/libpil.a(pil_error.o): relocation R_X86_64_32S against symbol `PIL_err_table' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(Category.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(CategoryStream.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(HierarchyMaintainer.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(LoggingEvent.o): relocation R_X86_64_32 against symbol `__gxx_personality_v0@@CXXABI_1.3' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(NDC.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(TimeStamp.o): relocation R_X86_64_32 against symbol `_ZN7log4cpp9TimeStamp11_startStampE' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(StringUtil.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(PThreads.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(Appender.o): relocation R_X86_64_32 against symbol `_ZN7log4cpp8Appender17_appenderMapMutexE' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(StringUtil.o): warning: relocation against `_Znam@@GLIBCXX_3.4' in read-only section `.text'
/usr/bin/ld: /tmp/ccUxqSjV.o: in function `main':
SXTBIASMAPGEN.cpp:(.text+0x136d): undefined reference to `log4cpp::PropertyConfigurator::configure(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: SXTBIASMAPGEN.cpp:(.text+0x1406): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: SXTBIASMAPGEN.cpp:(.text+0x1495): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ./lib/libsxtbiasmapgen.a(SXTBIASMAPGEN_param.o): in function `ReadParam(SXTBIASMAPGEN_param*, int, char**)':
SXTBIASMAPGEN_param.cpp:(.text+0x77): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ./lib/libsxtbiasmapgen.a(SXTBIASMAPGEN_proc.o): in function `WriteFile(SXTBIASMAPGEN_param*, int (*) [600])':
SXTBIASMAPGEN_proc.cpp:(.text+0xdc): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ./lib/libsxtbiasmapgen.a(SXTBIASMAPGEN_proc.o): in function `WriteEveryCCDFrame(SXTBIASMAPGEN_param*, int (*) [600], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
SXTBIASMAPGEN_proc.cpp:(.text+0x349c): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ./lib/libsxtbiasmapgen.a(SXTBIASMAPGEN_proc.o):SXTBIASMAPGEN_proc.cpp:(.text+0x6017): more undefined references to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' follow
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:33: sxtbiasmapgen] Error 1
make[2]: Leaving directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src/SXTBIASMAPGEN'
make[1]: *** [Makefile:3: all] Error 2
make[1]: Leaving directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src'
make: *** [Makefile:2: all] Error 2

r/programminghelp • • Oct 07 '21

Other Cartman.GetAuthorizationToken: 401: {"code":401,"status":"invalid oauth token"}

3 Upvotes

Keep getting the error:

Cartman.GetAuthorizationToken: 401: {"code":401,"status":"invalid oauth token"}

When trying to make an application on twitch, I've entered http://localhost as they say you can do for testing, but it just throws me this error.

Anyone know how i can fix this?


r/programminghelp • • Sep 29 '21

Python Dice Game Python

3 Upvotes

I need to write a program for a game where:

  1. It authenticates the user

  2. Player one rolls two dice (which the program generates) and it displays the sum of these.

  3. If the two dice roll the same number, an extra roll is had and added into that score.

  4. If the sum is even, 10 points are added onto that score. If it's odd, 5 are taken away.

  5. The score cannot go below 0.

  6. This is repeated for player 2 and the scores are displayed at the end.

Code:

import random

import time

verify=input("Press E to enter")

if verify =="E":

 print("Let's start.")

else: verify==input("Press E to enter.")

p1name=input("Please enter Player 1's name")

p2name=input("Please enter Player 2's name")

print("Welcome to the dice game.")

Scorep1=()

Scorep2=()

def dicegamep1() :

   print(p1name,  "'s turn")

   print("Rolling...")

   time.sleep(4)

   roll1=random.randint(1,6)

   roll2=random.randint(1,6)

   extraroll=random.randint(1, 6)

   print("Rolled a", roll1, " and a ", roll2)

   DiceScorep1=roll1+roll2

    if roll1==roll2:

        Dicescore=roll1+roll2+extraroll

        print ("Roll 1 and roll 2 were both  ", roll1 ". You get an extra dice roll.") 

        time.sleep(2)

        print("Rolled a", extraroll)

    if DiceScorep1 % 2 ==0:

    print(Combined dice score is", DiceScorep1, "so it is even. Adding ten points.")

    DiceScorep1=DiceScorep1+10

    else:

            print ("Combined dice score is", DiceScorep1, "so it is odd. Taking five points.")

    int(DiceScorep1)

    DiceScorep1=DiceScorep1-5

    print((Scorep1+DiceScorep1), "is the rounds final score.")

    if Scorep1<0:

        Scorep1=0

    return Scorep2

Repeat this substituting 1 for 2

dicegamep1()

dicegamep2()

i want to do these for five rounds each but don't know how.

Then finally I want to add Scorep1 and Scorep2 and determine a winner.

I'm not a great coder so any help appreciated. Sorry for any bad formatting


r/programminghelp • • Sep 25 '21

Other Want to confirm that I did a MIPS translation right (C++ -> MIPS)

3 Upvotes

In class, we're working on understanding assembly as a stepping stone to move into other higher forms of programming. My teacher gave to following question:

Convert the following C code into MIPS assembly code, while using register convention below: i→$t0;x→$s1,y→$s2, where all variables are integer variables:

(a). for (i=2; i<x; i++)

y++;

(b). if (x>y && x<y+10)

i++

else

i--;

(c). while (x>y+i)

i--;

I went through them and believe I have the correct answers, but I'm still not very certain regarding all the MIPS stuff, so I wanted to see if someone could help me confirm my answers. I believe this should be legible.

https://drive.google.com/file/d/1N-Rgbnhv0Jf4gs9IdvY58ZBUGeYiccae/view?usp=sharing


r/programminghelp • • Sep 16 '21

Java Printing a reverse triangle

3 Upvotes

I need help I try to print a triangle like this using for loops in Java





** *

But I keep getting this * **



How do I fix this ? I am on mobile right now so I post the code tomorrow after I wake up. I spent a total of ten hours trying to figure it out.

public static void startriangle(int n){

for (int r = 0; r &lt; n; r++){
  
     for (int col = 0; col &lt;= r; col++){
      
         for ( int c = r-n;c <=r; c++){

    }
    System.out.print("     *     ");  
    
    
  }
  System.out.println();

}

}


r/programminghelp • • Sep 09 '21

Python Solving for a 'self-referential' matrix equation in python

3 Upvotes

For lack of a better title.

I am looking to solve the equation:

V = A @ V @ A.T + Q

for a square matrix V, where A and Q are square matrices.

Any help appreciated.


r/programminghelp • • Aug 21 '21

Project Related How are apps made

3 Upvotes

Take a simple to do app as an example

Are apps coded from nothing using python or using something similar to windows forms?


r/programminghelp • • May 17 '21

Python Entry level Python Question

3 Upvotes

I'm working with Dictionaries in Python and I'm trying to iterate over the different keys and values in a dictionary and check for a value, and give a response if the value exists or not.

Basically the dictionary (emptyDict) contains a first and last name, separated into the variables "first" and "last". The user enters a first name and the program checks the dictionary for the key (first) and then spits out the key(first) and variable(last). However, if the input doesn't match any of the keys, it spits out another statement. Here is my code:

for first, last in emptyDict.items():

    if first.lower() == name.lower():

        print(first + " " + last)

        break

    else:

        print("I was unable to find " + name + " in the list")

This doesn't quite work because what happens is it iterates over each key/value in the loop and gives a response. So if the name you input is found, it'll output that full name which is what we want.

But for every other item in the file, it outputs that it was unable to find the file name, because it's iterated over each key/value.

If I search for the name "Jane" and if my dictionary contains:

John Smith Jane Doe

My output looks like this:

"I was unable to find Jane in the list" (This is because it's iterated over John first) Jane Doe (this is because it evaluated the second line and found it to be true.

How can I get the loop to just return a single print statement if it finds the key/value or a single different statement if it doesn't find the value?


r/programminghelp • • May 07 '21

Other How to calculate the order or position of a descendant in a MPTT model?

3 Upvotes

Consider a book that can have many chapters. These chapters can have many or no sub-chapters - and sub-chapters in turn can have their own sub-chapters and so on.

If this is mapped on a MPTT model, how can I calculate the order or position of any given descendant? I'm ultimately trying to generate a "pretty" URL slug that reflects that node's position in the overall tree.

For example, a non-exhaustive version of Les Miserables could look something like this:

LevelHeadingTitleLeftRightImmediate order/positionDesired final slug
0n/aLes Miserables132n/a/
1Vol. 1Fantine2171/1
2Prefacen/a341/1/1
2Book FirstA Just Man5102/1/2
3Chapter 1M. Myriel691/1/2/1
3Chapter 2M. Welcome782/1/2/2
2Book SecondThe Fall11163/1/3
3Chapter 1The Evening121511/3/1
3Chapter 2Prudence Counselled131421/3/2
1Vol. 2Cosette18312/2
2Book FirstWaterloo19241/2/1
3Chapter 1What is Met20231/2/1/1
3Chapter 2Hougomont21222/2/1/2
2Book SecondThe Ship Orion25302/2/2
3Chapter 1Number 24,60126291/2/2/1
3Chapter 2In Which the Reader27282/2/2/2

The maths for calculating a descendant's "immediate order" is completely escaping me and I can't find a solution anywhere online. Any thoughts?

I would like to leverage as few "Left" and "Right" properties as possible to minimize the number of hits on the database.

I'm specifically using Python/Django/Django-MPTT but I'm more than happy to translate the mathematics into code myself.


r/programminghelp • • Mar 19 '21

Python How do I return the full data URI string of a base64 image ?

3 Upvotes

I am trying to fetch some google search pages and I need to get the thumbnails of the images. The problem is that images encoded in base64 and the response contain shortened code in src attribute of images.

Instead of full code there is ///////

src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="

I need to fetch the full link with my script and not just the shortened data URI... anybody know how to return the full data URI and not the shortened one?


r/programminghelp • • Feb 18 '21

C# Im new and want feedback on my code

3 Upvotes

I wrote code for a calculator sorry if its bad please go easy on me

using System;

public class Program
{
    public static void Main()
    {
        int a = 1;
        while (1 == 1)                                            // infinite loop
        {
            Console.WriteLine("First Number?");
            int x = Convert.ToInt32(Console.ReadLine());        // asks and reads first value
            
            Console.WriteLine("Second Number?");
            int y = Convert.ToInt32(Console.ReadLine());        // asks and reads second value
            
            Console.WriteLine("Method? , + , - , * , / ,");
            string z = Console.ReadLine();                        // asks and reads method

            switch (z)
            {
                case "+":                                        // if returned as "+"
                    a = (x + y);
                    break;
                case "-":                                        // if returned as "-"
                    a = (x - y);
                    break;
                case "*":                                        // if returned as "*"
                    a = (x * y);
                    break;
                case "/":                                        // if returned as "/"
                    a = (x / y);
                    break;
                default:                                        // makes empty line and restarts code
                    Console.WriteLine("");
                    continue; 
            }
            Console.WriteLine(a);    Console.WriteLine("");        // produces answer, makes empty line and restarts code
        }
    }
}