C# :: ListBox Values And Arrays?

Sep 18, 2014

I'm making a simple airline reservation. I have two list boxes one has the section (A, B, C, etc) and the other rows (1, 2, 3, etc). I used two different arrays to put the values into the list box via form unload. The problem I can't seem to figure out is how can I update these seats and inform the user if a seat is taken or not. Lets say a customer takes A-1 (only seat taken). If I try to add someone else there it will inform me that seat is taken and to select another one. If all the seats are taken it'll tell me to put customer into the waiting list.

Also one more thing is that each row has 3 seats, so A-1, A-2, A-3 for example. If say A-1, A-2 are taken when I push a button show remain seats it should show A-3 only. I have a lot od struggle using arrays.

View 3 Replies


ADVERTISEMENT

C# :: Moving Listbox Selection To New Listbox In New Form?

Sep 11, 2014

Okay so i have everything right accept transfering the selectedindex from listbox in form1 to listbox in form2. I am using the below string item to hold the selected line of the list box, with the intent of recalling and then adding it into the form2 listbox. I get a not implemented error and i can't figure out why. I know the information is moving with the variable item, it just doesn't get printed out to the new listbox.

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string item = listBox1.SelectedItem.ToString();
Form2 form2 = new Form2();
form2.Show(item.ToString());

[Code]....

View 13 Replies View Related

C :: Assigning Values To Arrays / Printing Arrays

Jul 1, 2014

Using a for loop, construct two 100 element arrays, x and y, such that element i of x stores the value sin(2*pi*i/100)) and the corresponding element of y stores cos((2*pi*i/100)). Print the values stored in the elements of x and y as you calculate them.

I have attempted to solve it but I'm not sure why the value 0 is only being printed, maybe I haven't assigned sin(2i/100)) and cos((2i/100)) to the arrays properly?

Code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main () {

[Code] .....

View 3 Replies View Related

C++ :: Assigning Values To Arrays

Apr 13, 2013

Here is the code:

#include <iostream>
using namespace std;
int main(int argc, char * argv[])
{
double foo [5][5];

This is the warning:warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x...It's referring to the boldened part.

View 1 Replies View Related

C++ :: Storing Values In Arrays?

Feb 25, 2014

I'm am trying to get info from a file and put it into three arrays but it isn't working.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void sort(ifstream& infile){

[code]....

View 3 Replies View Related

C++ :: Why Overload Constructor Not Put Values Into Arrays

Jan 7, 2014

I'm still pretty new to classes so what am i doing in this code that is wrong.

#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string>
using namespace std;
class BunnyInfo{

[Code]...

View 6 Replies View Related

C/C++ :: Storing Values In Arrays Using For Loop

Nov 18, 2013

I am trying to create a program that will give me an value for a chosen from the user array ut I believe the program I've made does not recognize the values of the previous arrays. (Here is my program):

#include<stdio.h>
int main() {
int n;
int i;
int j;
float c;
float a[10000];

[Code] ....

There must be problem cause every value I give n(only for n=1 the answer is correct) the result is "a[n] is -inf"

View 1 Replies View Related

C++ :: Processing Structured Arrays - Too Many Initializer Values

Apr 22, 2013

I working on an assignment that processes an array of structs. In the main function I am attempting to declare an array of Author structures with 3 elements. It is supposed to be initialized to set all of the string fields (the names and book titles) to "NONE", and the double fields (the prices) to zero. This is supposed to be done in one statement, not using loops. Here is what I have.

struct BookInfo struct Author
{ {
string title; string authorName;
double price; BookInfo books[SIZE] //SIZE = 3
}; };

//prototype for function to print the content of array on screen
void showInfo(Author a[], int size);

[Code] .....

I was under the impression that an array can only hold the values of one data type. So doubles and strings in the same array doesn't make sense to me. However, that's the example my teacher drew up. The error keeps telling me that there are too many initializer values.

View 4 Replies View Related

C/C++ :: Function Not Returning Values - Structs In Arrays

Feb 25, 2015

I wrote this code for a homework assignment, everything runs fine but the function void percent_votes (line 66) isn't calculating properly, it outputs 0.00 for each value. I have tried everything I can think of to try and make it work.

Here is the assignment: Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate's name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election.

Here is the code I have written:

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

[Code].....

View 4 Replies View Related

C/C++ :: 2D Dynamic Arrays - How To Create And Give Values

Apr 23, 2014

I cant get with part of it is wrong, i want to sum every row, too.

// Color Number.cpp : Defines the entry point for the console application.
//  
#include "stdafx.h"
#include<conio.h>
#include<iostream>

[Code].....

View 1 Replies View Related

C :: Read Specific Values From A File And Store Them In Arrays

Apr 14, 2013

What i try to do is to write a code which reads some specific values from a file and stores them in an array. My File looks like this

Code:

XFOIL Version 6.96
Calculated polar for: Myfoil
1 1 Reynolds number fixed Mach number fixed
xtrf = 1.000 (top) 1.000 (bottom)
Mach = 0.000 Re = 0.200 e 6 Ncrit = 4.000
}

[code]...

View 11 Replies View Related

C++ :: Tree Arrays Of Same Even Lengths And Adds Values At Odd Indexes

Oct 22, 2013

I am trying a program with that takes tree arrays of same even lengths and adds the values at odd indexes and save at even index of 3rd array and voice versa........

what will be the logic i have tried it a lot of time not worked................

View 3 Replies View Related

C/C++ :: Transfer Array Values To Positive And Negative Arrays?

Oct 21, 2014

I have a problem with my assignment. I would like to ask how to transfer positive and negative values from array temperature to arrays positive and negative?

#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int n=0, d=0, temperature[20], sum;
int positive[], negative[];
float avg;

[code]....

View 5 Replies View Related

C/C++ :: How To Assign Values From Text File To Structure Of Arrays

Sep 5, 2014

have to do an election program in C.

There are 7 candidates and 365 votes in total. I need to do this using an array of structures. I need to read from a text file each of the names of the candidate and the number of votes they get. At the end i need to output the winner of the election.

Here is a sample of my code so far

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct candidates {
char name[20];
int votes;

[code]....

Here is a sample of my text file:

Robert Bloom
John Brown
Michelle Dawn
Michael Hall
Sean O’Rielly
Arthur Smith
Carl White

1 2 4 5 1 2 3 4 4 1 2 3 7 4 4 5 3 7 7 7 7 7 7 7 7 7

Each candidate gets +1 vote for their number electionCandidate[0] for each one he gets one vote and so on for the rest. 365 voters in total.

I was able to input the name for each Candidate from the text file. Now the problem is putting each vote to the corresponding candidate. Also any vote that is above 7 is a spoilt vote which i am trying to count in the above code. The code compiles but it crashes.

I am using while(!feof) but it seems that its not working or this is not the correct way.

View 6 Replies View Related

C/C++ :: Comparing Element Values In Dynamic Parallel Arrays

Oct 30, 2014

I've been working on an assignment that deals with newspaper advertisements. I have two arrays:

categoryCode (the code for the advertisement's category such as pets, cars, etc) and
numWords (number of words in the ad).

The arrays are dynamic.

My assignment has the category listed each time there is an ad associated with it and then its number of words for that ad. If this were a real-world issue I would want my output to list each category only once despite how many ads were in it, list how many individual ads are in the category, and its total number of words for the ads in that category. When using parallel arrays, is there a way to do this?

Let's say I have categoryCode with three elements {5, 5, 7} and numWords {10, 12, 15}.

How would I make the numWords add together only when the categoryCode values are the same?

I would want the output to print:
Category 5 Ads 2 Words 22
Category 7 Ads 1 Words 15

rather than how my instructor is having us do it like this:
Category 5 Words 10
Category 5 Words 12
Category 7 Words 15

I think I'm getting hung up because my mind is confusing the element's location in the array with the element's actual value and I'm probably making this harder than it should be. How would I compare the categoryCode values in a dynamic array? If it were a fixed size I think I could just compare categoryCode[0] to categoryCode[1] and so on, right? But in this case I'm not sure how I would go about that.

View 6 Replies View Related

C++ :: Values Are Changing When Passing Arrays And Array Sizes?

Feb 28, 2014

I'm working on a homework assignment that asks me to roll two die a user given number of times, find the roll sums, and a few other things. I'm working on it one module at a time and I'm running into two big problems so far.

The first problem is that my int variable rolls changes to a number within the random number generator range of numbers after I run rolldie. I got around this by making a const equal to the user entered value of rolls just so that I could continue developing the program.

My second problem is that the values of the arrays resultsOne[] and resultsTwo[] are changed after running findsum(). Why this is happening and I even tried passing them as const, but that changed nothing. We just started learning about passing arrays to functions, so there might be something big that I'm missing.

Code:
#include <iostream>
#include <cstdlib>
using namespace std;
void rolldie(int resultsOne[], int sizeOfresultsOne, int resultsTwo[], int sizeOfresultsTwo);
void findsum(int resultsOne[], int sizeOfresultsOne, int resultsTwo[], int sizeOfresultsTwo, int tossSums[], int sizeOftossSums);

[Code] ....

View 8 Replies View Related

Visual C++ :: Arrays - Solve Equation Using All Volume Values

Dec 22, 2012

I am using matlab R2o11 in which the programming medium is c++. I am having these variables=

T=373 t0 376
V=0.09 to 1
P=T/V

I just need a result showing ... First it should take T=373 and solve the equation using all volume values. Then it takes another temperature and do the same.

View 4 Replies View Related

C :: Function That Merge Content Of Two Sorted Arrays Of Double Type Values

Nov 4, 2013

I need to write a function that will merge the content of two sorted arrays of type double values. The function should not assume that both its input parameter arrays are the same length.

Here is my program so far - I know there is alot of errors and mistakes:

Code:

#include<stdio.h>
void merge(int firstArray[],int secondArray[],int size) {
int mergedArray[size],i=0,j=0,k=0;
while(i<size||j<size) {
if(i==size) {

[Code]...

View 2 Replies View Related

C/C++ :: Madd Libs Game - How To Store Inputted Strings Or Values To Arrays

Nov 11, 2014

My assignment is writing Madd Libs game. I still do not understand how to store inputted strings or values to arrays. I need explanation of collecting inputted data to arrays.

#include "stdafx.h"
#include<stdio.h>
//#include<string.h>
int main(void) {
char string[37] = {''};
char adjective1[15];

[Code] ....

View 14 Replies View Related

C++ :: Pass 2 Arrays Into Void Function And Return Values To One Function?

Feb 12, 2014

I'm trying to pass 2 arrays into a void funtion, and return values to one function.

this is the the program I'm working with, after I'm done I have to split it into 3 files, a header, a main, and a separate cpp file for the functions to live in.

#include <iostream>
using namespace std;
void processArrary(int numberCount[], int Numbers[], int intnumberSize, int numberCountSize);
int main() {
int Scores[26] = {76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189};
int numberCount[8] = { 0 };

[code]...

The goal of this program is to separate and count the groups of numbers then output the amount of numbers in each group. Near as I can tell, everthing should work, but I'm getting all zeros to be displayed in each group.

View 6 Replies View Related

C# :: Using Array In Listbox?

Jun 2, 2014

My main form I have the following code

[ImportingConstructor]
public MainForm([ImportMany] IEnumerable<AudioPlugin> content)
{

[Code].....

However, when I add to the listbox as shown above in my main form code the results all show on the same line. My understanding was that they should all be treated as separate because of foreach loop but apparently that is incorrect. I have seen mixed things online some showing that its required to use AddRange instead of Add, however, after literally hours of trying to make this work I am still coming up with nothing. I can't seem to get any code to work using the AddRange or am I finding any way to output each results on a separate line.

View 7 Replies View Related

C++ :: Listbox SendMessage Not Working

Jun 25, 2013

I have a problem with SendMessage. Anything I send doesn't show up but instead empty lines appear. What is wrong with my code?

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR greeting[] = _T("Hello, World!");
wchar_t listBoxStr[15];

[code].....

View 7 Replies View Related

C# :: Invert ListBox Selection?

Apr 18, 2014

I have my ListBox working and I'm able to select the items I want to keep. I'm trying to now get the Invert of the current selection for the items to delete.

I tried using:

if (lstLinePatterns == null) return;
for (int i = 0; i < lstLinePatterns.Items.Count; i++)
lstLinePatterns.Items[i].Selected = !lstLinePatterns.Items[i].Selected;

But
.Selected
is giving me an object error.

Is there an easy way to just inverse current selection?

Current Code:

private void btnSelectNonRvt_Click(object sender, EventArgs e)
{
// Unselects any Items to Prevent Infinite Loop
lstLinePatterns.SelectedIndex = -1;

[Code]....

View 3 Replies View Related

C# :: Clear A Listbox From A Class?

Jun 5, 2014

I need to clear a listbox from a class other than the form where it exists. Why this isn't working? I'm getting no error messages when I compile and I am seeing the Console.WriteLine text I also added in the same function. I can call this function from within my form and it behaves as expected. I tried setting the listbox to public despite the fact I wasn't getting protection level errors but that made no difference.

Just to clarify what I'm doing here... I have a form that includes a panel of user controls from another class. So there is a listbox on OtherClass and the listbox is in MyForm. Heres my code:

MyForm

public void ClearListBox() {
Console.WriteLine("echo");
listBox.Items.Clear();
} OtherClass
private void listBox_SelectedIndexChanged(object sender, EventArgs e) {
MyForm mf = new MyForm();
mf.ClearListBox();
}

View 9 Replies View Related

C# :: Two Checked Listbox - One Interacts With Other

Aug 31, 2014

I am working on a Windows From application on Visual Studio 2010 where i need to use two checkedlistbox that interacts one with the other one. Let say that the first checkedlistbox is for world regions (i.e.):

Asia
Africa
Europe
South America

And let say that the second checkedlistbox is for Countries (i.e.):

Spain
Italy
Romania
Monaco

(all of this belongs to Europe region)

What we need to do is that when the user check on any world region it automatically checks all the countries on that region in the second checkbox, and vice versa if the users check any country on the second checkedlistbox it automatically seconds the region on the first one.

I know that is possible in Java and we know how to do it, but i don't know if C# supports this and how to do it. I was looking on the class information in the microsoft website: [URL] .... but not a concrete example on how to do it.

View 5 Replies View Related

C# :: Listbox Loop - Getting Value Of Both Cards

Apr 3, 2015

I have a lstYourHand that has two cards in it, I loop through the listbox to get the values of both cards. I take the string value of the listbox item (strCardVal) and use a switch to give it an integer value (intCardVal). For some reason, when I run the code, the message Box at the end gives me the value 0 as a result, it does not register me giving it a value in the switch statement. My code is below:

Int32 intCardVal = 0;
String strCardVal;
Int32 intLoopCounter1;
for (intLoopCounter1 = 0; intLoopCounter1 == 1; intLoopCounter1++) {
strCardVal = lstYourHand.SelectedItem.ToString();

[Code] .....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved