logo
Tags down

shadow

My code outputs invalid when I input anything


By : Chapol Rafsan
Date : October 17 2020, 06:10 PM
it should still fix some issue The >> operator for std::string reads only up to the first whitespace character. So you'd only ever see "whole" or "decimal", which doesn't match what you're checking for.
I'd recommend using getline() instead. It will read an entire line of input.
code :


Share : facebook icon twitter icon

Trouble with array outputs and prompting for user-input outputs


By : ru_
Date : March 29 2020, 07:55 AM
it should still fix some issue For your first problem just shift your Scanners inside your read_input method so they start fresh each time.
code :
public static void main(String[] args) {
    Employee emp1;
    Employee emp2;

    emp1 = read_input("first");

    emp2 = read_input("second");

    System.out.println(emp1.toString());
    System.out.println(emp2.toString());

}

public static Employee read_input(String msg) {
    Scanner scan1 = new Scanner(System.in);
    Scanner scan2 = new Scanner(System.in);
    Scanner scan3 = new Scanner(System.in);
    ...
public String addBonus(double[] empBonus)
{
    StringBuilder arrayBonus = new StringBuilder();

    for(int i=0; i<empBonus.length;i++)
    {
        arrayBonus.append(empBonus[i] + ", ");
    }

    return arrayBonus.toString();
}

Why my code only outputs part of the input string?


By : 江宇博
Date : March 29 2020, 07:55 AM
it helps some times thank you for reading. I am a new programmer in an introductory programming class, and I only have a month's worth of training in C++. I have tried to fix this code with many approaches, but I don't know why it only prints one word of my input string: , Replace:
code :
cin >> x;
std::getline(std::cin, x);

Code in C that has the user input 10 numbers and outputs them in a certain order


By : zifan
Date : March 29 2020, 07:55 AM
With these it helps Welcome to C, Don! There are many ways to approach this, but let's stick with your array utilization....
1) set the input into an array
code :
for (i=0; i < 5; i++)
{
    for j=9; j > 4; j--)
    {
        printf("%d %d\n", array[i], array[j]);
    }
}

How to store an input (TextCtrl) into a variable, process it through some code-lines and show the outputs in another win


By : user3398286
Date : March 29 2020, 07:55 AM
To fix this issue When you use classes and you need to access something across methods inside a class, then you need to create the variable by prepending it with self. So in SavePhrase, you need to create var as self.var if other parts of the class need access to it
If you want to show the results in a separate window, then I would create a new wx.Frame instance inside of SavePhrase and pass it your var. Then you don't need to call it self.var unless something else in MyFrame itself needs to access var.
code :
import wx

class OtherFrame(wx.Frame):
    """
    Class used for creating frames other than the main one
    """

    def __init__(self, var, title='Other Frame', parent=None):
        wx.Frame.__init__(self, parent=parent, title=title)
        self.var = var
        print('var = {}'.format(var))
        self.Show()


class MyFrame(wx.Frame):
    def __init__(self, *args, **kw):
        super(MyFrame, self).__init__(*args, **kw)
        panel = wx.Panel(self)
        my_sizer = wx.BoxSizer(wx.VERTICAL)

        my_sizer.AddStretchSpacer()

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        manual = wx.StaticText(panel, label='1) Inserisci la citazione --> ')
        font_manual = wx.Font(10, wx.SCRIPT, wx.NORMAL, wx.NORMAL)
        manual.SetFont(font_manual)
        hbox.Add(manual)
        manual2 = wx.StaticText(panel, label='2) Clicca sul logo Bibliovago --> ')
        font_manual2 = wx.Font(10, wx.SCRIPT, wx.NORMAL, wx.NORMAL)
        manual2.SetFont(font_manual2)
        hbox.Add(manual2)
        manual3 = wx.StaticText(panel, label='3) Buona lettura')
        font_manual3 = wx.Font(10, wx.SCRIPT, wx.NORMAL, wx.NORMAL)
        manual3.SetFont(font_manual3)
        hbox.Add(manual3)
        my_sizer.Add(hbox,0, wx.ALIGN_CENTER)

        my_sizer.AddStretchSpacer()

        istr = wx.StaticText(panel, label='Inserisci una citazione')
        font_istr = wx.Font(14, wx.MODERN, wx.NORMAL, wx.NORMAL)
        istr.SetFont(font_istr)
        my_sizer.Add(istr, 0, wx.ALL | wx.CENTER, 5)

        self.text_ctrl = wx.TextCtrl(panel)
        my_sizer.Add(self.text_ctrl, 0, wx.ALL | wx.EXPAND, 5)

        logo_button = wx.Bitmap('LOGO.png')
        self.my_btn = wx.BitmapButton(panel,-1,logo_button)
        self.Bind(wx.EVT_BUTTON, self.SavePhrase, self.my_btn)
        my_sizer.Add(self.my_btn, 0, wx.ALL | wx.CENTER, 5)


        panel.SetSizer(my_sizer)

        my_sizer.AddStretchSpacer()

    def SavePhrase(self, event):
        var = self.text_ctrl.GetValue()
        frame = OtherFrame(var=var)


if __name__ == '__main__':
    app = wx.App()
    frm = MyFrame(None, title='BiblioZam', size = (600,400))
    frm.Show()
    app.MainLoop()

How can I DRY a code which takes in several inputs, executes the same function for each input, and gives all for outputs


By : user3583283
Date : March 29 2020, 07:55 AM
will help you I'm writing a code that can calculate and display the crosswind component for 4 runways at the same time.Between the inputs(selected runways) and output(crosswind component), I have 4 blocks of code that uses the same calculation for each runway. For the sake of simplicity I wrote a replex: , It's simple Python. You can do something like this:
code :
value = []

for i in range(1, 5):
    runway = int(input("Enter the {}st runway".format(i)))
    crosswind = runway * 2
    value.append(crosswind)

print(value)
Related Posts Related Posts :
  • Definition of a C++ variable, section Basic/6
  • How to add arithmetic operators to std::array?
  • Is it possible to to create a vector filled with zeros of size N using template meta programming in c++11
  • Problem about implementation of a stack in C++
  • Which of these pointer comparisons should a conforming compiler be able to optimize to "always false"?
  • Data Structure to represent command packet format
  • Can't find the error in my cpp or header file, class construction failing
  • How can I find substring in a vector in c++
  • Is it possible to pass std::deque's member functions as a parameter?
  • check if elements of a range can be moved?
  • How to pass a function as parameter in C++
  • What is the difference between _malloca and malloc?
  • is there an way to ignore signals signature?
  • Valgrind Invalid Read of Size 8 for insertion sort
  • C++ Template Specialization and Subclassing
  • C++ autoload default constructor on object property
  • Adding node to linked list without explicitly allocating memory space (without using new)
  • Why does "unsigned int" + "unsigned int" return an "unsigned int"?
  • Is there a reason why Clang does not optimize this code?
  • Returning a reference to a class data member and then trying to change that member
  • Why does a private struct defined in a .h require a scope in a return type in the .cpp file?
  • c++ wrapper for header encapsulation
  • Does a super class need a default constructor?
  • Generate random number and guaranteed to cover all between the given domain?
  • I'm trying to use something other than a boolean function
  • What is the principle for behavior of boost adding month?
  • Is there a way find a key in the whole json file using QJsonObject?
  • Why is my code printing the wrong ciphertext?
  • Forcing inlining of callback (lambda) in C++17 in library
  • How can I use Valgrind to determine the source of "still-available" memory leak?
  • Set intersection in C++ on the keys of a map
  • Assigning a Char Value to a Vector Element. C++
  • Why does the line "subsets.push_back(n);" give me an error in the following code?
  • converting double * to std::vector<double> gives me error
  • When adding text to mouse location on click giving segmentation fault
  • How to generate auto id in c++?
  • Can I use reduce instead of a for loop?
  • Which STL container could grow in both directions?
  • How to generate 7 random numbers, without repeats
  • Get the first value (string) in a map from the second value (int)
  • c++ conditional uni-directional iterator
  • How to use two constructors?
  • std::vector< base_class * > iterate using base but call derived classes function
  • Why doesn't C++ allow implicit list initialization in the conditional operator?
  • How i can use a eleven-digit number
  • Why is my destructor called only once and not on the delete(a) call?
  • Aggregate initialization of array of structs using array
  • Unexplained different omp_get_wtime() for the same exact computation
  • How to increase the length of a sequence of numbers in vector
  • C++ - Undefined reference to `vtable (constructor)
  • Float to string without rounding
  • C++: Copy elision when passing std::unique_ptr (move-only type) rvalue as parameter
  • Is it possible to use an #if directive with a template non-type argument? (Vector all-in-one class)
  • How to stop positional light moving with camera
  • How to configure opencv in Eclipse for Java developers with plugin CDT?
  • How to split string read from text file into array using c++
  • Compute hash of map structure
  • How to solve the problem that multithreaded drawing is not smooth?
  • How to initialize dynamic array inside a class?
  • Is there any leak of memory in my code when i pass pointer to vector
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk