How would you write this into pseudo code?

558fe5180e0e8fc922d31c23ef84d240

How would you write this into pseudo code

#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])

//variables
string var, var1;
float cm, mile, kilometer, inch, meter, AU, fahrenheit, celsius, foot, quit, i;
//program
i = 1;
while (i <= 1000000000) 
    cout << "Enter the starting unit. For a list of all units and commands, type list. To exit, type quit. Please note that this program will only loop one billion times." << endl <<endl;
    cin >> var;
    cout << endl;

        if (var == "quit")

                return 0;

        //list of functions
        if  (var == "list")

            cout << "For cm to inch type centimeter. For inch to cm type inch. For miles to km type mile. For km to miles type kilometer. For meters to AU or feet type meter. For AU to meters type AU. For feet to meters type feet. For fahrenheit to celsius type fahrenheit. For Celsius to Fahrenheit type celsius then rerun the program." << endl << endl << endl;

        //inches to centimeters
        if  (var == "inch")

            cout << "Please enter the number of inches" << endl;
           cin >> inch;
            cm = inch * 2.54;
            cout << "Distance in centimeters:" << endl;
            cout << cm << endl;

        //centimeters to inches
        if  (var == "centimeter")

            cout << "Please enter the number of centimeters" << endl;
            cin >> cm;
            inch = cm / 2.54;
            cout << "Distance in inches:" << endl;
            cout << inch << endl;

        //miles to kilometers
        if  (var == "mile")

            cout << "Please enter the number of miles" << endl;
           cin >> mile;
            kilometer = mile * 1.609344;
            cout << "Distance in kilometers:" << endl;
            cout << kilometer << endl;

        //kilometers to miles
        if  (var == "kilometer")

            cout << "Please enter the number of kilometers" << endl;
            cin >> kilometer;
            mile = kilometer / 1.609344;
            cout << "Distance in miles:" << endl;
            cout << mile << endl;

        //meters to AU or feet
        if  (var == "meter")

            cout << "Please select which unit you would like to convert meters to out of Astronomical units and feet" << endl;
            cin >> var1;
            //AU
            if  (var1 == "AU");

                cout << "Please enter number of meters" << endl;
               cin >> meter;
                AU = meter / 149598000000;
                cout << "Distance in AU:" << endl;
                cout << AU << endl;

            //feet
            if  (var1 == "feet")

                cout << "Please enter number of meters" << endl;
                cin >> meter;
                foot = meter * 3.2808399;
                cout << "Distance in feet:" << endl;
                cout << foot << endl;

        //AU to meters
        if  (var == "AU")

            cout << "Please enter number of AU" << endl;
            cin >> AU;
            meter = AU * 149598000000;
            cout << "Distance in meters:" << endl;
            cout << meter << endl;

        //feet to meters
        if  (var == "feet")

            cout << "Please enter number of feet" << endl;
            cin >> foot;
            meter = foot / 3.2808399;
            cout << "Distance in meters:" << endl;
            cout << meter << endl;

        //fahrenheit to celsius
        if  (var == "fahrenheit")

            cout << "Please enter temperature in Fahrenheit." << endl;
            cin >> fahrenheit;
            celsius = (fahrenheit - 32) * (5 / 9);
            cout << "Temperature in celsius:" << endl;
            cout << celsius << endl;

        //celsius to fahrenheit
        if  (var == "celsius")

            cout << "Please enter temperature in Celsius." << endl;
            cin >> celsius;
            fahrenheit = (celsius * (9 / 5)) + 32;
            cout << "Temperature in Fahrenheit:" << endl;
            cout << fahrenheit << endl;

    i++;

system("PAUSE");

Five Ways of Synchronising Multithreaded Integration Tests

558fe5180e0e8fc922d31c23ef84d240

A few weeks ago I wrote a blog on synchronizing multithreaded integration tests, which was republished on DZone Javalobby from where it received a comment from Robert Saulnier who quite rightly pointed out that you can also use join() to synchronize a worker thread and its unit tests. This got me thinking, just how many ways can you synchronise multi-threaded integration tests? So, I started counting... and came up with:

  1. Using a random delay.
  2. Adding a CountDownLatch
  3. Thread.join()
  4. Acquiring a Semaphore
  5. With a Future and ExecutorService


Clojure: Destructuring

558fe5180e0e8fc922d31c23ef84d240

In The Joy of Clojure (TJoC) destructuring is described as a mini-language within Clojure. It's not essential to learn this mini-language; however, as the authors of TJoC point out, destructuring facilitates concise, elegant code.

Making Code More Understandable

One of the scariest things for those who are just now learning how to do some coding is the fact that they have to try to figure out what a seemingly impossible set of rules and structures means for the work that they are trying to do. It is not easy at all, and many people struggle with it in big ways. 

Why is my py code not working as intended?

558fe5180e0e8fc922d31c23ef84d240

Hi guys, i am new here. Been on this code for some days and i seem stuck and not getting the expected output from this code.
first the code functions as a FIFO QUEUE where it takes input from the user and put it at the beginning of a list while deleting the last item on the list and creating a new list.
then i did function to search for four floating numbers (1.3,1.4,1.5,1.6) in the new list such that any float in the list that has identical integer part and decimal part split like any of the four floating numbers(1.4, 1.5, 1.6, 1.3) is denoted as a variant of the float e.g 17.34, 35.19 and 30.01 will be variants of float 1.3. Similarly 12.56, 57.17 and 10.50 will be variant of float 1.5. Also,a float like 14.31 if present in the list will be regarded as a variant of both 1.3 and 1.4 while float 15.61 will be regarded as a variant of both float 1.5 and 1.6.
So anytime the code runs, it takes the first THREE numbers each in the list or queue that are variants of 1.3,1.4,1.5 and 1.6 and create a new list for each variant. for example

list1 =[1.72, 10.60, 34.21,18.40, 11.13, 45.33, 1.03, 35.91]
this list has 4 variants of float 1.3
the new lists that will be created for float 1.3 from this list when i run the search function is:

new list a=[1.72, 10.60,34.21]

new list b=[1.72, 10.60, 34.21, 18.40,11.13]

new list c=[1.72, 10.60,34.21, 18.40, 11.13,45.33,1.03]

Lastly, the code performs a reverse indexing on each of the 3 new list with the second to the last number on each list having an index of 1 and third to the last digit having an index of 2. if there is any number in each of the new list that is equal to or greater than 2 with the same index index number, then there is a match. and the functions returns an output. the number only has to be equal to or greater than 2 but the index must match for all 3 new list.

from the above lists, the code returns an output like this" there is a match at index 1 for variant 1.3"

attached to this post is the code i have written. its a bit longer than it should if not i would have posted it on here. it runs without any problems for the first run, but subsequently fails to bring out expected output when i change the number in the list or when the queue FIFO starts working.

i will be happy if anyone can take a look and help check whats wrong with it or help modify it to work as i want

Need help with tKinter Scrollbar, doesnt attach to listbox

558fe5180e0e8fc922d31c23ef84d240

from tkinter import *

app = Tk()

label1_text = StringVar()
part_label = Label(app, bg='#dfe3ee', text='Check1', font=('bold',12), pady=10, padx=20)
part_label.grid(row=0, column=0, sticky=W)
label1_entry = Entry(app, textvariable=label1_text)
label1_entry.grid(row=0, column=1)

label2_text = StringVar()
part_label = Label(app, bg='#dfe3ee', text='Check1', font=('bold', 12), pady=7, padx=20)
part_label.grid(row=1, column=0, sticky=W)
label2_entry = Entry(app, textvariable=label2_text)
label2_entry.grid(row=1, column=1)

label3_text = StringVar()
part_label = Label(app, bg='#dfe3ee', text='Check3', font=('bold', 12), pady=20)
part_label.grid(row=0, column=2)
label3_entry = Entry(app, textvariable=label3_text)
label3_entry.grid(row=0, column=3)

label4 = StringVar()
part_label = Label(app, bg='#dfe3ee', text='check4', font=('bold', 12), pady=7)
part_label.grid(row=1, column=2)
label4_entry = Entry(app, textvariable=label4)
label4_entry.grid(row=1, column=3)

B1_btn = Button(app, bg='#cd8de5', text='Button1',font=('bold', 11), width=12)
B1_btn.grid(row=3, column=1, padx=0, pady=5)

B2_btn = Button(app, bg='#cd8de5', text='Button2',font=('bold', 11), width=12 )
B2_btn.grid(row=4, column=1, padx=0, pady=5)

B3_btn = Button(app, bg='#d5a6e6', text='close',font=('bold', 11), width=12)
B3_btn.grid(row=50, column=2, sticky='E')

output_list = Listbox(app, height=20, width=100, border=5)
output_list.grid(row=20, column=0, columnspan=3, rowspan=6, pady=20, padx=20)

scrollbar = Scrollbar(app)
scrollbar.grid(row=20, column =3, rowspan=5, sticky=(N+S))

output_list.configure(yscrollcommand=scrollbar.set)
scrollbar.configure(command=output_list.yview)

app.title('Test Tool')
app.geometry('900x900')
app.configure(bg='#dfe3ee')

app.mainloop()

to calculate final score

558fe5180e0e8fc922d31c23ef84d240

i already done the scores for each round, i dont know how to calculate the scores for all round, can u help me to solve this?

#include <iostream>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;


//Global variable
const string cardfile=("cards.txt");


//Function Prototypes
void readCards();
int RandomCardP1 (int);
int RandomCardP2 (int);
int CheckType (int [], int ,int);
int CheckSystem (int [], int ,int );
void ShowCardP1(int , string [], string [], string [], string[] , string []);
void ShowCardP2(int, string [], string [], string [], string [], string []);
int Score(int ,int ,int [],int []);
int FinalScore (int,int);


int main(){

    //score
    int sctype[SIZE]={ 3,2,1,2,3,4,1,2,2,2 };
    int scsystem[SIZE]={ 6,4,2,1,5,7,1,2,3,5 };


    //loop for game
    do{
    int scP1=0,scP2=0; 

    for (int round=1;round<6;round++)
    {//loop for 5 round

        cout <<"\t***********";
        cout<<endl<<"\t  ROUND "<<round<<"\n";
        cout <<"\t***********";
        cout<<endl;


    //announce winner and score for each round
    Score(IDcardP1,IDcardP2,sctype-1,scsystem-1);
    cout<<endl;

    cin.get();
    cout<<endl<<endl;


    }//end loop for round


    //score total round
    FinalScore(scP1,scP2);


   } while(respond=='Y'||respond=='y');//end loop for game



}//end main


//scores for each round
int Score(int IDcardP1,int IDcardP2,int sctype[],int scsystem[]){

    int scP1=0, scP2=0;
    cout << "The winner for this round is " <<endl<<endl;
    if (sctype[IDcardP1]>sctype[IDcardP2])
    {
        cout << "  PLAYER 1  " <<endl;
        scP1+=10;
        cout<<endl;
    }
    else
    {
        if (scsystem[IDcardP1]>scsystem[IDcardP2])
        {
            cout << "  PLAYER 1  " <<endl;
            scP1+=10;
            cout<<endl;
        }
        else
        {
            cout << "  PLAYER 2  " <<endl;
            scP2+=10;
        }
        cout<<endl;
    }

    //display score for each round
    cout << "The scores for this round"<<endl;
    cout<<"####################################"<<endl;
    cout<<" Player 1 score :"<<scP1<<endl;
    cout<<" Player 2 score :"<<scP2<<endl;
    cout<<"####################################"<<endl;

}

//score for all round
int FinalScore(int scP1,int scP2){

    //score total round
    cout << "+++++++++++++++++++++++++++++++++"<<endl;
    cout << " Your scores for 5 round : "<< endl;
    cout << " Player 1's score: " << scP1<<endl;
    cout << " Player 2's score: " << scP2<<endl;
    cout << "+++++++++++++++++++++++++++++++++"<<endl;
    cout <<endl;

    //announce the winner for this game
    if (scP1>scP2)
        cout << "\tPLAYER 1 WON!" << endl << endl;
    else
        cout << "\tPLAYER 2 WON!" << endl << endl;
    cout<<endl;
}

cannot read the txt file

558fe5180e0e8fc922d31c23ef84d240

hi guys, i dont know why when i run the code, its shows my txt is not found, here i attached the txt.file and the coding :)
i just follow the coding in the example that lecturer given, but yeah as i mentioned before, the txt cannot be found :( i hope u guys can help me

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

//Prototype
void readCards();

int main()
{

    readCards();

    return 0;
}

void readCards(){

    const int CARDS = 10;
    int ID[CARDS];
    string cardName[CARDS] ;
    string pcode[CARDS];
    string type[CARDS];
    string plusMode[CARDS];
    string system[CARDS] ;
    int i=0;

    ifstream infile;
    infile.open("cards.txt");
    if (infile)
    {
        while (!infile.eof()){

            //Read from file
            infile >> ID[i] >> cardName[i] >> pcode[i] >> type[i] >> plusMode[i]>>system[i];
            i++;

        }
        infile.close();

    }
    else
    {
        cout << "File cannot be found.\n";
        exit(0);
    }
}

User Premissions

558fe5180e0e8fc922d31c23ef84d240

Hello
I create project based on c# , and i make roles like admin and users , so that i want to give special premission to users to perfom tasks .

if anyone know how i can make or write this code , please help me .

and in advance THANKYOU.

Need help counting occurences of a letter from a file

558fe5180e0e8fc922d31c23ef84d240

Need help, been stuck on this the past couple days i dont really understand how to get my code to read from my file and count each occurence of a letter wheter they are uppr or lower case and output them to a file, just need help with the counting part, have to do it all through a function.

Here is my source code:

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void getData(ifstream& inPara, ofstream& outChara, char texT[], int numLet[]);

int main()
{
    ifstream inFile;
    ofstream outFile;
    char ch[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    int numofCharacters[26] = {0};
    char target;

    inFile.open("Lab7.txt");//opens input file

    if (!inFile)//runs error if inFile could not be opened
    {
        cout << "Error unable to open Input File" << endl;
        cout << "Program Terminated!" << endl;
        return 1;
    }

    outFile.open("Output.txt");//opens Output File

    if (!outFile)//runs error if Output File could not be opened
    {
        cout << "Error unable to open Output File" << endl;
        cout << "Program Terminated!" << endl;
        return 1;
    }
    while (!inFile.eof())//runs program untile end of file
    {
        inFile >> target
    }

    inFile.close();
    outFile.close();

    return 0;
}

void getData(ifstream& inPara, ofstream& outChara, char texT[], int numLet[])
{

    for (int i = 0; i < 26; i++) {
    if (texT[i]) {
        numLet[i]++;
        }
    }
    for (int i = 0; i < 26; i++) {
        cout << numLet[i] << " " << endl;
    }
}

Writing Into a txt file using linked list. The code I have listed is for re

558fe5180e0e8fc922d31c23ef84d240

This is the code for reading from a txt file, but creating a code for writing into a txt file that goes along with this reading code is pretty difficult and am looking for any ideas that can help me in implementing this using linked list along with txt files

I want to create a code to write Into a text file that goes along with the read code that I have listed down all using linked list.
Any ideas would be a big help and appreciated

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

using namespace std;

struct person_tag
{
    string name;
    string id;
};

struct course_tag
{
    string course_name;
    int no_of_units;
    int marks[4];
    double avg;
};

struct tutor_tag
{
    person_tag tutor_info;
    course_tag course_info;
    tutor_tag *next;
};

typedef struct tutor_tag Tutor_Tag;
typedef Tutor_Tag *Tutor_TagPtr;

Tutor_Tag *hptr;
Tutor_Tag *cptr;
Tutor_Tag *nptr;

//function protypes
void menu();
void read();
void display_tutors();

void
read()              //readfile function
{
    hptr = nptr = NULL;              //intialized to null
    string filename = "tutors.txt";
    ifstream inFile(filename);

    if (inFile.fail())               // if file doesnt open successfully
    {
    cout << "The File was not opened successfully\n";
    cout << "Please check that the file currently exists\n";
    exit(1);
    }
    while (true)         // until the end of the file
    {
    cptr = new Tutor_Tag;
    cptr->next = NULL;
    // Read the data into the new item
    inFile >> cptr->tutor_info.name;
    inFile >> cptr->tutor_info.id;
    inFile >> cptr->course_info.course_name;
    inFile >> cptr->course_info.no_of_units;
    for (int j = 0; j < cptr->course_info.no_of_units; j++) {
        inFile >> cptr->course_info.marks[j];
    }

    // Did you read it okay?
    if (inFile.fail()) {
        delete cptr;    // don't need it
        break;
    }

    // Okay, you read it. Add to the list
    if (hptr == NULL) {
        // First item in the list. Point hptr at it
        hptr = cptr;
    } else {
        // Not the first item, append it to the tail.
        nptr->next = cptr;
    }
    nptr = cptr;        // Move the tail pointer
    }
    inFile.close();              //close file
}

void
display()
{
    tutor_tag *ptr;
    ptr = hptr;
    while (ptr != NULL) {
    cout << "The Tutor Name: " << ptr->tutor_info.name << "  \n";
    cout << "The Tutor ID: " << ptr->tutor_info.id << "  \n";
    cout << "The course name: " << ptr->course_info.course_name << "  \n";
    cout << "Number of units " << ptr->course_info.no_of_units << "  \n";
    cout << " Rating recieved: \n";
    for (int j = 0; j < ptr->course_info.no_of_units; j++) {
        cout << ptr->course_info.marks[j] << "  \n";
    }
    cout << "The marks average is : " << ptr->course_info.avg << "  \n";
    ptr = ptr->next;
    }
}

int
main()
{
    read();
    cout << "The linked list is: ";
    display();
    return 0;
}

Script that mounts and checks if a file has been modified

558fe5180e0e8fc922d31c23ef84d240

First, it has been a LONG time since Ive been here. Good memories from when I was young.

Anyways

In a monitoring system I have, I had a plugin that remotely checked a SMB share and if the file hasnt been modified in 1 day, it should return a warning. if it is 2 days or more, it should return a critical.

Returning the warning and the critical isnt the issue, its the entire logic of the script itself.

I mean, I dont think it should be too difficult but Im not used to shell scripting. Also, the downfall exists, of having to check if the mount is correct, etc.

The logic is basically

inputvariable warningdays
inputvariable criticaldays
inputvariable smbpath
mount smbpath to final folder /mnt/folder
if mount is unsuccessful
return unknown
if mount is successful
if /mnt/folder/file does not exist
return unknown
if /mnt/folder/file does exist
if /mnt/folder/file has been written to less than warningdays
return ok
if /mnt/folder/file has been written to more than warningdays and less than criticaldays
return warning
if /mnt/folder/file has been written to more than criticaldays
return critical
if previousoperations are done
unmount
if unmount is unsuccessful
return unknown
finish

Could someone tell me the basics of the shell script?

Thank you.

Can someone help me fix this code

558fe5180e0e8fc922d31c23ef84d240
#include<iostream>
using namespace std;
int main()
{
char LtrGrade;
cout <<"Enter a letter grade: ";
cin>> LtrGrade;
switch (LtrGrade)
{
case "a":
case "A":
cout<<"\nExcellent";
break;
case "b":
case "B":
cout<<"\nSuperior";
break;
case "c":
case "C":
cout<<"\nAverage";
break;
case "d":
case "D":
cout<<"\nPoor";
break;
case "e":
case "E":
cout<<"\nTry Again";
break;
default:
 cout<<"\nNo match was found for the ENTRY"
 <<LtrGrade<<endl;
}
return 0;
}