Latest Computer Science Posts

Now that your code display is fixed can you answer more questions?

  1. Where are your brackets? { and }
  2. Line 8 looks odd. Read http://www.cplusplus.com/doc/tutorial/basic_io/ to see how to use cout.

There's more but as presented this won't work in any C++ compiler I know of.

The include had # as the first char so it was interpreted as heading, thus the big font. I fixed it and now you can see the target as <iostream>.

rproffitt commented: Much better looking. Thank you. +0

It may be too late for you to fix your post. That first line in such a big font states include but what?

Also take time to share what's not working and the error messages since many may not load up your project to see what is amiss. Besdes the first few lines look off to me.

#include <iostream>
using namespace std;

int main()

    float firstgrade, secondgrade, thirdgrade, fourthgrade;

    cout << "Enter your grades: ">> intl; 
    cin >> firstgrade >> secondgrade >> thirdgrade >> fourthgrade;

    // Determining letter grades
    const int
        A = 90,
        B = 80,
        C = 70,
        D = 60;

    float average=0.0;
    average = (float)(firstgrade + secondgrade + thirdgrade
        + fourthgrade) / 4;
    cout << "The average of their grades is: " << average;

    //What is your letter grade?
    if (average >= 90)

        cout << "Your average is an A. \n";

    else if (average >= 80)

        cout << "Your average is a B. \n";

    else if (average >= 70)

        cout << "Your average is a C. \n";

    else if (average >= 60)

        cout << "Your average is a D. \n";

    else if (average >= 0)

        cout << "Your average is an F. \n";

    else

        cout << "Invalid test score.\n";

    return 0;

I need help with a code for averaging grades it works on a online compiler but it doesn't work on visual studio 2019

Wow. Thanks for sharing :)

Thank you so very much for such detailed instructions! Really helpful tutorial!

This post will you to Recover Lost JEE Main Application Number & Password. Don’t worry, the process to recover the JEE Main Application Number or Password is quick and simple!

A very well-knit explanation of all Python operators is available here: https://www.techbeamers.com/python-operators-tutorial-beginners/#comparison-operators

I think MSI is the best for gaming. It's can do everything for gamer.

I first encountered Voronoi maps back in 1992 when an article was published in Dr. Dobb's Journal relating to mapping. Several months later, I was approached by a guy who wanted to build a GPS-driven real-time moving map display that ran in a portable laptop-style computer. I went back to that article, played around with it, and realized it was a perfect solution. I ended up working with this client for a while. We licensed the library from the vendor and I built what may have been one of the earliest things we commonly refer to as "GPS units" today. We were at least 5 years ahead of Garmin, Magellan, and others. Unfortunately, the client ran the company into the ground before it got anywhere, which was really sad to see.

The magic of this approach was we were able to take 85MB of geographical data from USGS (which was a LOT back then!) and translate it into a database that represented data points in "chunks", thereby shrinking the total data down to 16MB.

Traditionally, geographical data is represented as Lat/Lon coordinate pairs, that need to be saved as double-precision floating-point numbers. All of the math for this format is fairly complicated trigonmetric algorithms that processes large arrays of these relatively huge data tuples. Computers with Floating Point CPUs (FPUs) were around twice the cost of others, so my client wanted a solution that didn't require an FPU. Without an FPU, the same algorithms ran REALLY SLOWLY!

By employing Voronoi ...

If not interested in theory and just want to see an application, please visit https://github.com/jeffmylife/casual/blob/master/Voromap.ipynb for a notebook on an easy-to-understand practical application of Voronoi diagrams.
Or visit wikipedia's https://en.wikipedia.org/wiki/Voronoi_diagram#Applications list of applications.

This is great. As to practical use this saved hundreds of lives in 1864 when a pump handle was removed.
Today it is used to visualize answers to questions such as "nearest location for most customers" and more.

As it's one in your arsenal of graphical data presentation it's nice to see one with quite the history attached to it.
https://en.wikipedia.org/wiki/1854_Broad_Street_cholera_outbreak notes the "dot map" which is now known as a Voronoi diagram.

All very technical and graphical.but until you give me at least one practical use, I'm not interested

jeffmylife commented: https://github.com/jeffmylife/casual/blob/master/Voromap.ipynb +0
What Are Voronoi Diagrams?

Voronoi Diagrams are an essential visualization to have in your toolbox. The diagram’s structure is a data-driven tessellation of a plane and may be colored by random or to add additional information.

Learn the Lingo

The set of points that generate the Voronoi diagram are called “seeds” or “generators” for they generate the polygon shapes; in practice, the seeds are your cleaned data. Each seed generates its own polygon called a Voronoi “cell,” and all of 2-dimensional (2D) space is associated with only one cell. A Voronoi cell, or Voronoi “region” denotes all of the space in the plane that is closest to its seed. Cell boundaries shared between two regions signify the space that is equally distant, or “equidistant”, to the seeds.

Formal Definition

Given a distance metric dist and a dataset D of n 2-dimensional generator coordinates, a Voronoi diagram partitions the plane into n distinct regions. For each seed k in D, a region Rk is defined by the Region equation.

region_eq.png

In English, the equation is “This region is equal to the set of points in 2D space such that the distance between any one of these points and this generator is less than the distance between the point and all other generators.” To fully understand the math, be sure to map the words to every symbol in the equation. It’s important to recall that a generator, Dk, comes from the input data, whereas points in ...

rproffitt commented: Good work. Thanks for sharing. +15

This had me check out if such an app has been written before in C. This lead me to the linux and other OSes "tac" command.

The source code weighs in at about 700 lines so I won't post it here but just a link.
https://github.com/coreutils/coreutils/blob/master/src/tac.c

No conversion required at all. Use the source Dawit.

THIS IS THE CODE

#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<string.h>

using namespace std;

int main(int argc, char *argv[]){

    string data[1000];
    int i,j;
    ifstream fin("input233.txt");
    if (!fin){
        cout << "Error opening file\n";
        return 0;
    }
    int count = 0;
    while(getline(fin,data[count])){
        count++;
    }
    if (argc == 1){
       int i = 0;
       int j = count - 1;
       while (i < j){
          string temp;
          temp = data[i];
          data[i] = data[j];
          data[j] = temp;
          i++;
          j--;
       }
       for (int i = 0; i<count; i++)
           cout << data[i] << endl;
    }
    else if (argc == 2){
        i = 0;
        j = count - 1;
        while (i < j){
          string temp;
          temp = data[i];
          data[i] = data[j];
          data[j] = temp;
          i++;
          j--;
        }
        if (strcmp("-c",argv[1])== 0){
           for (int i = 0; i< count; i++){
               int m = 0;
               int n = data[i].length()-1;
               while(m<n){
                  char temp = data[i][m];
                  data[i][m] = data[i][n];
                  data[i][n] = temp;
                  m++;
                  n--;
               }
               cout << data[i] << endl;
           }     
        }
        if (strcmp("-r",argv[1]) == 0){

           for (int i = 0; i<count; i++){
               string list[20];
               stringstream ss(data[i]);
               int count1 = 0;
               while(ss >> list[count1])
                    count1++;
               int r = 0;
               int s = count1-1;
               while(r < s){
                  string temp1 = list[r];
                  list[r] = list[s];
                  list[s] = temp1;
                  r++;
                  s--;
               }
               for (int w = 0; w<count1; w++)
                   cout << list[w] << " ";
               cout << endl;              
           }
        }     
    }
    return 0;
}

The reverse program shown in the slides of chapter 13-1 (also present in the book) reads from a file/command line using system calls and outputs the lines in reverse order on the terminal. The last line is swapped with the first line , the second last is swaped with the second line and so on. It also has a -c option to run with. When used with -c option it reverse the characters of each line as well. For example,

Lets say below are the file contents of your file.

This is line 1

This is line 2

This is line 3

This is line 4

This is line 5

When executed without the -c option the output on terminal would be as follows:

This is line 5

This is line 4

This is line 3

This is line 2

This is line 1

(The order of lines are reversed, fifth line then fourth line then third and so on.) When you run the program with -c option the output would be as follows

After reversing the order of lines, the characters of each line are also reversed. Your homework should you choose to accept it (Of course you have too :P) is to implement this and also implement a -r option. Everything would work the same until the user uses -r option instead of -c. When -c option is used then you would not swap each character of a line rather you would reverse each word. So when used ...

My thought is one leaves space in the form and the other does not.

What are differences between Visibility.Collapsed and Visibility.Hidden in WPF?

I created a calculator only using the scripting commands in the video game Counter-Strike, bind (for input) echo (for output) and alias (for the logic). Bind is to connect keys to a command or string of specified commands, echo is to output text to the console, and alias is a command that allows you to create a new command out of a string of specified commands. Basically, I can do math without using math. This is pure connectionism, where there are no values, no logic operators and no measurements in the logic. It is purely making, breaking and using connections and nothing else.

The first few paragraphs from my paper that I am working on:

How To Compute Without Variables, Logic Operators or Measurements

Work in progress

I have come up with what I believe is a new type of logic, it is mechanical in nature, but because I could maybe see it done on the quantum level it could be far more complex than any mechanical machine has ever been, in ways not seen in physical mechanical devices.

This logic is pure connectionism, only using connections and nothing else. I look at it as a geometry of logic. My system performs the logic only using one command without numeric variables, without logic operators, and without measurements. This is neither digital nor analog logic.

This is not theory, I have built a working model using this logic that demonstrates if-then, do-while, a randomizer, a relational database and other logic, including ...

def max(firstNumber, secondNumber):

if firstNumber > secondNumber:
    return firstNumber
else:
    return secondNumber

def getNumbersFromUser():

userFirstNumber = int(input("Please enter the first number: "))
userSecondNumber = int(input("Please entter the second number: "))
return userFirstNumber, userSecondNumber

def main():

userFirstNumber, userSecondNumber = getNumbersFromUser()
print("The maximum number between", userFirstNumber, "and", \
      userSecondNumber, "is", max(userFirstNumber, userSecondNumber))

main()

This is my program code

That's pretty low level stuff that you should be able to handle just by rereading your class notes. If you don't know how to flowchart a simple if-then structure then you've probably been sleeping in class.

What, specifically, is giving you problems?

The neat thing about pseudocode is it has defied hard standards. I can't guess if your class has defined it to be in some format so I'll take pseudocode to be "resembling a simplified programming language, used in program design." Since this is just resemblence and not standardized your attempt at pseudocode will do nicely. It's much like writing a book. You get better the more you do.

Design a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two.

NEED HELP WITH >>>>>>>>>>>>>>>>> variable lists, IPO Chart, pseudocode, Flowchart

Introduction

This tutorial provides guidance on gathering data through web-scraping. However, to demonstrate the real-life issues with acquiring data, a deep-dive into a specific, complicated example is needed. The problem chosen, acquiring the geographic coordinates of gas stations in a region, turns into an interesting math problem that, eventually, involves "sacred geometry".

Application Programming Interfaces (API's)

No matter which Data Science Process model you subscribe to, actually acquiring data to work with is necessary. By far the most straightforward data source is a simple click-to-download in a standardized file format so you can utilize a parsing module in your favorite language; for example, using Python’s pandas.DataFrame.from_csv() function parses a .csv into a DataFrame object in one line .

Unfortunately, it’s not always this easy. Real-time data, like the stream of 6000 tweets per second, can’t simply be appended to an infinitely-growing file for downloading. Furthermore, what happens when the dataset is extremely large? Smaller organizations might not be able to provide several-gigabyte downloads to each user, and if someone only needs a small subset, then giving them everything would be inefficient.

In general, these problems are solved through an Application Programming Interface (API). API’s are a programmer’s way of interfacing with an application, or in the context of this article, the means by which we will acquire data. Here's a great, concise resource on why API’s are needed .

One quick note. API’s are typically different from one another, so it’s not necessary to learn every ...

Reverend Jim commented: Nicely Done. Bookmarked for later. +15
Intro

Receiver Operating Characteristic (ROC) plots are useful for visualizing a predictive model’s effectiveness. This tutorial explains how to code ROC plots in Python from scratch.

Data Preparation & Motivation

We’re going to use the breast cancer dataset from sklearn’s sample datasets. It is an accessible, binary classification dataset (malignant vs. benign) with 30 positive, real-valued features. To train a logistic regression model, the dataset is split into train-test pools, then the model is fit to the training data.

from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import *
from sklearn.model_selection import train_test_split

# Load datasetd
dataset = load_breast_cancer()

# Split data into train-test pools 
train, test, train_labels, test_labels = train_test_split(dataset['data'],
                                                          dataset['target'],
                                                          test_size=0.33)

# Train model 
logregr = LogisticRegression().fit(train, train_labels)

Recall that the standard logistic regression model predicts the probability of a positive event in a binary situation. In this case, it predicts the probability [0,1] that a patient’s tumor is ‘benign’. But as you may have heard, logistic regression is considered a classification model. It turns out that it is a regression model until you apply a decision function, then it becomes a classifier. In logistic regression, the decision function is: if x > 0.5, then the positive event is true (where x is the predicted probability that the positive event occurs), else the other (negative) event is true.

With our newly-trained logistic regression model, we can predict the probabilities of the test examples.

# Rename, listify 
actuals = list(test_labels)

# Predict probablities of test data [0,1] ...
rproffitt commented: Thanks. I found https://scikit-learn.org to have some good resources I hadn't seen before as well. +15
Dani commented: Thank you so much for contributing this! +16

"If something sounds too good to be true, then it probably isn't true. When it comes to situations like this, think from a business perspective. What do they get out of this ? Even if you say they may be doing this for the well being, running an academy requires money to be spent.
""""If you don’t get a job, you don’t need to pay a penny""."" This line may have got your attention, but our persectives differ. So if you do get the job, how much are you required to pay ?
If you really want to pursue tech courses, go for some popular sites like Coursera, Udemy, etc which does provide the courses from a reliable source."

Dani 1,760

They count on folk not reading or understanding what they are agreeing to. You can bet there is no time limit on you landing that job or there is a hidden finance, collection fee there. All this has been seen before. You are being ripped off.

It's my understanding that it's common practice for them to hire their recent graduates as TAs. Does the fine print say anything about minimum salary requirements?