Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

One of my favourite games.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Still safe and healthy here in Winnipeg.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you are interested, here is one implementation using pandas. Note that the first line in the data file must be

Routes,Passengers

import pandas
import sys

df = pandas.read_csv("airlines.csv")

# calculate total flights per airline

totals = {}

for route,passengers in zip(df['Routes'],df['Passengers']):
    airline,*rest = route.split()
    totals[airline] = totals.get(airline,0) + passengers

# print out the totals for each airline and find max total

maxpassengers = 0

for airline,passengers in totals.items():
    print(airline, passengers)
    if passengers > maxpassengers:
        maxpassengers = passengers
        maxairline = airline

print("\nmax airline is",maxairline,'with',maxpassengers,'passengers')
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm curious. I frequently use a VPN. How will that affect my location?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I presume you heard what happened in Wisconsin? A 10-year seat on the state supreme court opened up and the GOP forced an election at the height of the pandemic figuring that

  1. Democrats would be too afraid to go to the polls to vote
  2. Republicans would be too stupid not to

In spite of all efforts to

  1. Close numerous polling stations
  2. Disenfranchise Democrats
  3. Restrict mail-in absentee voting
  4. Gerrymander districts

The GOP candidate still lost by a 10% margin. Now I'm waiting to see how the GOP manages to rule the election invalid. Incidentally, the GOP still retains a one vote majority on the state supreme court but the writing is on the wall.

rproffitt commented: As to the voting, the current destruction of the US Mail is underway, BIG TIME. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The White House is also allowing banks and creditors to seize the $1200 relief cheques if those receiving them have any outstanding debts. So not only is the vast majority of the billions going to "those that got", they've also managed to funnel most of the relief money into the hands of "those that got". Any excuse to rob the public purse before they (hopefully) get their sorry asses tossed in November.

I'm sure that if the Dems sweep the House &Senate (and White House) we will hear the GOP screaming that "it's time to look forward, not back" and "what's done is done".

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That would be me. And thank you.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm glad we finally got there. I seem to have had a blind spot about the meaning of the last column though. I hope that didn't cause too much confusion.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you are going to use pandas then forget the standard file open and just do

df = pd.read_csv("airlines.txt")

and keep in mind thatin your for loop, Airline will contain both the airline name and the route name. For example, one line of

Alitalia Rome      180

will give you "Alitalia Rome". You might want to try

for route,flights in zip(df['Airline'],df['Flights']):

and then separate the airline portion by

airline,*rest = route.split()

If you are unfamiliar with this expression, what it does is to split the string using a space as a delimiter. The first token (the airline) goes into airline and the remaining tokens go into rest. This saves you from an error if the route has more than one word.

Once you have the dictionary built you'll still need to iterate through it to find the entry with the largest number of flights.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I heard about this thing called Google. You might try that. I find the phrase "where can I download pip for linux" works pretty well.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

10 years for me. Same comments as James but different languages. Never benn a java fan.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That's sort of pseudo-code but still too code-ish. Try to write it like you are telling a person how to do it step-wise with pencil and paper. Your pseudo-code shouldn't have terms like 'open file', 'string', 'integer', or whatever a 'boucle' is.

There is a very useful feature in Python called a Dictionary. A dictionary uses key-value pairs. Unlike a list which you index by an integer, a dictionary is indexed by a key which can be any type. If you use the airline name as the key and the number of flights as the value you can keep a running total for each airline. The only gotcha is that you have to check if the key already exists, so your code looks like

totals = {}     # create an empty dictionary

If you split each line into three fields named airline, route and flights then you can do

if airline not in totals: totals[airline] = 0
totals[airline] += flights

So take that and try to figure out the rest.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Let's have a look at what you have now following my suggestions first.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Although I don't know why you are importing collections when you aren't using them, and I think you are over-complicating things by using pandas dataframes for such a simple application. I suggest you write your process as pseudo-code before you try to write actual code. Debug your pseudo-code on pencil and paper first with a small dataset example.

From what I can see you need to add a header line to your CSV to name the columns. For example, if your file looks like

Airline,Flights
Alitalia Rome,180
Alitalia Pisa,82
Germanwings Munich,96
Germanwings Frankfurt,163
NorwegianAir Bergen,202
Wizzair London,184
Wizzair Frankfurt,83
Wizzair Lisbon,198

then to iterate through the records you could do

for airline,flights in zip(df['Airline'],df['Flights']):
    print(airline,flights)

There are likely other ways to do this but I got this from a brief look at the 'getting started' guide. Let me know how it goes and where you are stuck and we can take it from there. I'll check back in a couple of hours.

medsibouh commented: Good +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I've never user pandas or collections but I noticed that although

from collections import counter

does not work,

from collections import Counter

does (upper case c in Counter). Perhaps that will help. I also noticed that the data you posted is not comma delimited,

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you want to see a brilliant and effective Covid-19 public service ad then check out this video. It gets the point across about social distancing in a way that makes immediate sense. Whoever created this deserves a Clio Award.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You still haven't shown us that you have put any effort into doing this yourself. If you don't pony up then this thread will likely be ignored.

rproffitt commented: Giddyup. +15
Samuel_33 commented: I have been trying tom paste a copy but having a tough time doing that +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

For future reference, if you want to count bits in an integer you should make it an unsigned int, and use bitwise shift right operations rather than division.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I was in the process of writing a response and after two sentences I realized I had already put more effort into replying than you did in creating the original post. Please show us what you have and where you are stuck.

Samuel_33 commented: #include <iostream> #include <fstream> using namespace std; /* The SMM Insurance Management System */ //function prototypes void displayMenu(); void +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

When I was in school I did my own homework. You should do the same. It's called "learning". You might also want to reread your post. Instead of "can you please help me with this" it comes off more like "Here's my homework. Do it for me." The first is a request. The second is just a rude demand.

So let's try this again. What have you done so far and where are you stuck?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Can't do much without seeing your code.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You do realize my answer was rife with sarcasm. I provided exactly as much good code as the OP provided bad code.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

And what do you expect us to do with that? I could write up a GUI that simulates a coin toss but I doubt that would be of any use.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Welcome to Daniweb. What part of Arizona are you from (I've been to Tempe a couple of times).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

When asked, "What language should I learn first?", my answer is always "English". If you can't communicate clearly then you can't do your job as a programmer properly. As a programmer your job does not begin and end with code. You must also be able to write documentation clearly. I recently came across two excellent technical writing modules by Google that are free for everyone. They do not take long to complete and (aside from the confusion between acronyms and initialisms) are spot on. You can find the overview here with links to the two main modules.

A lot of you are shut in for the duration of the Covid-19 outbreak anyway so you have no reason not to at least have a look.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Several things:

  1. Remove lines 14-17. You are prompting for and reading input that you never use.
  2. You don't have brackets around your two statements after the else if so only the first is part of the block.
  3. Why are you summing the salaries? That wasn't part of the spec.
  4. You need to pick better counter names than count and lcount.
  5. Your spec doesn't match your code.

For the last point, your spec (incorrectly, I presume) says to count how many are over and how many are under. According to the spec you should ignore those that are equal. Try

int over    = 0;
int notover = 0;

do {

    cout << "Enter a yearly salary: R";
    cin  >> yearlySalary;

    if (yearlySalary > LIMIT)
        ++over;
    else
        ++notover;

    cout << "Are there any more values to be input? ('Y' or 'N') ";
    cin  >> answer;

} while (answer == 'Y' || answer == 'y');

cout << "There are " << notover << " salaries that do not exceed R100 000." << endl;
cout << "There are " << over    << " salaries that exceed R100 000." << endl;
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try

$stmt = $pdo->prepare("INSERT INTO 'download' ('IP_ADDRESS', 'FILENAME') VALUES (?, ?)");

Note the small change from ") to )")

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

As I recall (it's been a while) you right click on the toolbox and select Choose items then browse to whatever custom control you want to include. In my case I didn't actually create a custom control that can be used this way. I just subclassed the existing control and added a bit of functionality. You could just put the code in a module and include or copy it into an existing project.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Only if you want the entries to be along the diagonal like

x - - -
- x - -
- - x -
- - - x
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You declare the dimensions of island as [4,1] but you index the columns as 0, 1, 2, 3 (lines 2-5). Did you mean to do

island[0, 0] = "Nassau" + "210";
island[1, 0] = "Freeport" + "$350";
island[2, 0] = "HarbourIsland" + "$400";
island[3, 0] = "MarshHarbour" + "$275";
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

i try but i didn't get the right input

Your program doesn't have any input. Your problem is in lines 23-49. Here is the correct code.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

We won't do your homework for you, but if you show us what you have tried so far and where you are stuck perhaps we can help.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Well, mine was a commonly word use by Mad Magazine and I think it is the Polish word for "need" although at the time I thought it was just gibberish.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

There is no direct way to do that but I'd like to point out a potential problem. What do you do when a week straddles two months?

If you still want to have months with weeks under you might use a tab control with one month per tab. That has the benefit of not requiring horizontal scrolling.

andre.jonker commented: thanks for the quick answer. I go for you solotion +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

And welcome to Daniweb

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Potrzebi.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

One final comment. Your spec said to calculate the number of salaries over a limit and how many below a limit. Ac cording to the stated spec you should ignore anything that equals the limit. You'll have to adjust either the spec or the code.

rproffitt commented: Great Scott! Code to the spec and wait for the client to tell you that's not what they meant. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

By the way, Code Snippet is to be used only for fully debugged and working (and fully commented/documented) code snippets. It is not to be used for posting buggy code. You should be posting as Discussion/Question.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You need to put brace brackets around your two statements. Indenting is not enough.

    else if (yearlySalary <= LIMIT) {
        totalSalaryB += yearlySalary;
        lcount++;
    }

But your problems extend beyond that. If the code, according to your spec, is only supposed to calculate the number of salaries below and above a limit then why are you totalling the actual salaries? And why are you bothering to do prompting and input above the loop? And while I am on it, count and lcount are poor variaible names.

Because this is so close to your actual code I don't mind posting this.

int main()
{
    float yearlySalary;
    const int LIMIT = 100000;
    char answer;
    int over = 0;
    int notover = 0;

    do
    {
        cout << "Enter a yearly salary: R";
        cin  >> yearlySalary;

        if (yearlySalary > LIMIT)
            over++;
        else
            notover++;

        cout << "Are there any more values to be input? ('Y' or 'N') ";
        cin  >> answer;
    } while (answer == 'Y' || answer == 'y');

    cout << "There are " << notover << " salaries that do not exceed R100 000." << endl;
    cout << "There are " << over    << " salaries that exceeds R100 000." << endl;

    return 0;
}
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

According to the FCC Regulations:

  • The FCC prohibits broadcasting false information about a crime or a catastrophe if the broadcaster knows the information is false and will cause substantial "public harm" if aired.

  • The FCC is prohibited by law from engaging in censorship or infringing on First Amendment rights of the press. It is, however, illegal for broadcasters to intentionally distort the news.

So how is it, exactly, that Fox "News" is allowed to continiue broadcasting, especially with all the false information they keep spouting about Covid-19?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The evil in the world comes almost always from ignorance, and goodwill can cause as much damage as ill-will if it is not enlightened. People are more often good than bad, though in fact that is not the question. But they are more or less ignorant and this is what one calls vice or virtue, the most appalling vice being the ignorance that thinks it knows everything and which consequently authorizes itself to kill. The murderer’s soul is blind, and there is no true goodness or fine love without the greatest possible degree of clear-sightedness.

  • Albert Camus (1947)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Not a single one. Something seems to be crowding out all the fluff news stories.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Could this be solved by "clear your cache"?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

There is a maximum size but I don't know what it is. If your avatar fails to upload, keep downsizing it until it works.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I take it this is homework? I suggest you read the Daniweb Posting Rules, particularly the Keep It Organized section. Alse read Suggestions For Posting Questions.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Is it your plan to post all your homework here for someone else to do? You also posted the "reverse words" question and found a kind-hearted person to do it for you. One such post gets a rebuke. Two in a row gets a snarky answer. Wanna try for three?

Aman_24 commented: lamest man i have i ever judged just by his comment. +0
rproffitt commented: Thank you for this, good man. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I would not attempt a conversion lacking descriptive comments and a spec.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

So you legally changed your name to that of your website? That's commitment. I might have gone with Dorothy Com (Dot Com for short) ;-P

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
  1. Backup the entire hard drive
  2. Wipe the OS partition
  3. Install the OS of your choice
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

just how you can configure an experience?

I'd start by lowering my expectations.