Questions
Create Python Code using a "for" loop and a "while" loop. You are starting a twelve...

Create Python Code using a "for" loop and a "while" loop. You are starting a twelve week program training to compete in a triathlon. The triathlon consists of three athletic events, 1.5 k swim, 40k bike, 10k run. In order to be prepared for the competition you want to print a training schedule. Starting with week 1 you will increase the distance of each activity so that you reach the race distance by week twelve. Due to rounding, you may be just under or over, and that’s okay. Display output to 2 decimal places. Since you want your program to be flexible, the program should the prompt for the athlete’s name and current level of each activity. Also allow the user to continue to enter training information for athletes until they say ‘no’ to the question “do you want to enter another”.

In: Computer Science

```please convert this code to make only using for loop not while loop #include #include #define...

```please convert this code to make only using for loop not while loop

#include
#include
#define MAX_SIZE 500

int main()
{
char str[MAX_SIZE];
char tosearch[MAX_SIZE];
char part1[100];
char part2[100];
int cursor = 0, i, cnt1 = 0, cnt2 = 0, cnt = 0;
int j = 0;
int a = 0;
int b = 0;
int total = 0;
printf("Enter any string: ");
gets(str);
printf("Enter word to search occurrences: ");
gets(tosearch);

for (i = 0; i < strlen(tosearch); i++)
{
if (tosearch[i] == '*')
{
for (j = 0; j < i; j++)
{
part1[j] = tosearch[j];

}

a = j;
}

}

for (j = 0; j < strlen(tosearch) - a; j++)
{
part2[j] = tosearch[a + j + 1];
}

for (j = 0; j < a; j++)
{
printf("%c", part1[j]);

}
printf("\n");

for (j = 0; j < strlen(tosearch) - a - 1; j++)
{
printf("%c", part2[j]);
}

printf("\n");
b = strlen(part2);


while (cursor < strlen(str)) { // while the cursor is smaller than length of main string while loop goes on

while (cnt1 != a) { // if the cnt1 is smaller than the part1 length the while loop goes on
  
if (str[cursor] == part1[0]) { // if the str[cursor] is correspond to the first word of part1 go to for loop

for (i = 0; i < a; i++) {

if (str[cursor + i] == part1[i])
{
cnt1++; // count the number of matching letter of part1 and main string

}
else { // else the cnt1 goes to 0 again and cursor goes forward
cnt1 = 0;
cursor++;
break;
}
}
}
if (cursor > strlen(str) || cnt1 == a)
{
  
break;
}
cursor++; // cursor goes to the next letter
}

cursor += a; printf("the value of cursor %d ", cursor);
  

while (cnt2 != b) { // if cnt2 is less than the length of part2 the while loop goes on


if (str[cursor] == part2[0]) { // if the str[cursor] correspond with part2[0] for loop goes on

for (i = 0; i < b; i++) {

if (str[cursor + i] == part2[i])
{
cnt2++; // count the matching letter of str and part2
}

else {
cnt2 = 0; // else cnt2 goes to 0 and cursor move on break free from the for loop
cursor++;
break;
}
}
}
if (cursor > strlen(str) || cnt2 == b) // if the cursor is larger than the strlen or cnt2 == (the length of part2) break free
break;

cursor++; // move on to the next letter of the main string
  
}

if (cursor + b > strlen(str))
break;

cnt++;
cnt1 = 0;
cnt2 = 0;
}
printf("tot %d\n", cnt);
}

In: Computer Science

9- Matthew has a new job as business analyst. He plans to invest 10 percent of...

9- Matthew has a new job as business analyst. He plans to invest 10 percent of his annual salary after the tax into a retirement account at the end of every year for the next 30 years. Suppose that annual return of the investment is 6%, and his current salary before tax is 90k which grow 3% per year. The tax will apply as 15% on the salary up to 50k and it is 20% for the salary interval of 50k and 80k and the tax rate will be 25% for the remaining salary more than 80k (for example if his salary will be 105k, he is paying 15% tax on his first 50k and 20% in the next 30 k and 25% on his next 25k of his salary). then: a) Create a spreadsheet which shows Matthew the balance of retirement account for various levels of annual investments and returns. b) If Matthew aims to gain $1,000,000 at the end of the 30th year, what percentage of his salary he should put in the investment annually.

In: Computer Science

A. Consider the following relations and relationship: JobOpening (jobNo, positon, salary, requirement, contactPerson) NewsPaper(newsPaperNo, name, street,...

A. Consider the following relations and relationship:

JobOpening (jobNo, positon, salary, requirement, contactPerson)

NewsPaper(newsPaperNo, name, street, city, zipCode, phoneNo)

       Posting(jobNo, newsPaperNo, date, cost)

1. List all the positions that are posted on January 01, 2016

2. List all the positions that have never been posted

3. List the names of all the newspapers where the positions “database administrator has been posted

In: Computer Science

How do I start to code in mysql to Alter table to modify column remove not...

How do I start to code in mysql to Alter table to modify column

remove not null constraint

First drop the foreign key associated with

Drop the column

Add the column back with new definition

Add the foreign key back

This Is what I wrote so far

alter table employees modify column repotsTo remove null:

In: Computer Science

Python 3.7.4 (Introductory Level) You want to know your grade in Computer Science: Write a program...

Python 3.7.4 (Introductory Level)

You want to know your grade in Computer Science:

Write a program that continuously takes grades between 0 and 100 to standard input until you input "stop", at which point it should print your average to standard output.

In: Computer Science

Separate code into .cpp and .h files: // C++ program to create and implement Poly class...

Separate code into .cpp and .h files:

// C++ program to create and implement Poly class representing Polynomials
#include <iostream>
#include <cmath>
using namespace std;

class Poly
{
private:
int degree;
int *coefficients;
public:
Poly();
Poly(int coeff, int degree);
Poly(int coeff);
Poly(const Poly& p);
~Poly();

void resize(int new_degree);
void setCoefficient(int exp, int coeff);
int getCoefficient(int exp);

void display();
};

// default constructor to create a polynomial with constant 0
Poly::Poly()
{
// set degree to 0
degree = 0;
// create an array of size 1
coefficients = new int[degree+1];
coefficients[0] = 0;
}

// parameterized constructor to create a polynomial with degree degree whose coefficient is coeff
Poly::Poly(int coeff, int degree)
{
this->degree = degree;
// create an array of size degree+1
coefficients = new int[degree+1];
// loop to set all the entries to 0
for(int i=0;i<degree;i++)
coefficients[i] = 0;
// set coefficient of degree to coeff
coefficients[degree] = coeff;
}

// parameterized constructor to create a polynomial with constant coeff
Poly::Poly(int coeff)
{
// set degree to 0
degree = 0;
// create an array of size 1
coefficients = new int[degree+1];
// set coefficients of constant to coeff
coefficients[0] = coeff;
}

// copy constructor to create a Polynomial same as p
Poly::Poly(const Poly& p)
{
// set degree
degree = p.degree;
// create a new array of size degree+1
coefficients = new int[degree+1];
// loop to copy the coefficients
for(int i=0;i<=degree;i++)
coefficients[i] = p.coefficients[i];
}

// destructor to release the memory allocated
Poly::~Poly()
{
delete[] coefficients;
}

// function to resize the polynomial to new_degree if new_degree > degree
void Poly:: resize(int new_degree)
{
if(new_degree > degree) // validate new_degree > degree
{
// create a new temporary array of size new_degree+1
int *temp = new int[new_degree+1];
// loop to copy coefficients to temp
for(int i=0;i<=degree;i++)
temp[i] = coefficients[i];

// loop to set the coefficients entries to 0
for(int i=degree+1; i<=new_degree; i++)
temp[i] = 0;

// release memory of existing array
delete[] coefficients;
// update degree
degree = new_degree;
// set coefficients to point to temp
coefficients = temp;
}
}

// function to set coefficient of exp to coeff
void Poly:: setCoefficient(int exp, int coeff)
{
// validate exp to be between [0,degree]
if(exp >= 0 && exp <= degree)
{
coefficients[exp] = coeff;
}
}

// function to return the coefficient of exp
int Poly::getCoefficient(int exp)
{
// validate exp to be between [0,degree]
if(exp >= 0 && exp <= degree)
return coefficients[exp];
return 0; // invalid exp, return 0
}

// function to display the polynomial
void Poly:: display()
{
bool firstTermDisplayed = false;

// loop from degree to 0
for(int i=degree; i>=0 ; i--)
{
if(coefficients[i] != 0) // ith coefficients is non-zero
{
if(firstTermDisplayed) // first term displayed
{
if(coefficients[i] > 0) // display sign between terms
cout<<" + ";
else
cout<<" - ";
cout<<abs(coefficients[i]); // display absolute value of coefficient
}
else // first term being displayed
{
cout<<coefficients[i];
firstTermDisplayed = true; // set firstTermDisplayed to true
}

// display the power of x
if(i > 0)
{
if(i == 1)
cout<<"x";
else
cout<<"x^"<<i;
}
}
else if(i == 0 && !firstTermDisplayed) // if polynomial is 0, display the constant 0
cout<<coefficients[i];
}
}


int main()
{
// test the Poly class
Poly A(5, 7), B(2), X;
Poly C(A);
cout<<"A: ";
A.display();
cout<<endl<<"B: ";
B.display();
cout<<endl<<"X: ";
X.display();
cout<<endl<<"C: ";
C.display();

A.setCoefficient(0, -2);
A.setCoefficient(1, 10);
A.setCoefficient(3, -4);
cout<<endl<<"A: ";
A.display();

B.resize(5);
B.setCoefficient(2, 10);
cout<<endl<<"B: ";
B.display();

return 0;
}

//end of program

In: Computer Science

How is the first argument passed to a function in x86-64 assembly? Give an example of...

How is the first argument passed to a function in x86-64 assembly? Give an example of this happening in assembly and the corresponding C code.

What x86-64 register is changed to allocate local variables? Explain briefly with an example.

In: Computer Science

what are the four pillars of design And discuss them?

what are the four pillars of design And discuss them?

In: Computer Science

Program Specification: (Visual Studio C++) 1. Read data for names and weights for 15 people from...

Program Specification: (Visual Studio C++)
1. Read data for names and weights for 15 people from the console where there is a name on a line followed by a weight on the next line.
2. Your program will build a list for the data maintained in ascending order based on both name and weight via a doubly linked list.
3. This dll will use one pointer to keep weights in sorted order, and use the other link to keep names on sorted order.
4. You need to build the list as you go maintaining this ordering, so at any time a print method was called it would print the related field in order. (This means nodes are added to the list in sorted order, elements are not added to the list followed by a sort called on the list.)

For example after 3 elements are added for (Name – Weight):
Michael – 275, Tom – 150, Abe – 200.

Output:
Names & weights sorted(ascending) by name. : Abe – 200, Michael – 275, Tom - 150
Names & weights sorted(ascending) by weight. : Tom – 150, Abe – 200, Michael - 275

Jim
150
Tom
212
Michael
174
Abe
199
Richard
200
April
117
Claire
124
Bobby
109
Bob
156
Kevin
145
Jason
182
Brian
150
Chris
175
Steven
164
Annabelle
99

In: Computer Science

*C PROGRAMMING LANGUAGE* a) Given an array of size n, sort the array using pointers using...

*C PROGRAMMING LANGUAGE*

a) Given an array of size n, sort the array using pointers using malloc or calloc. Examples: Input: n = 5, A= {33,21,2,55,4} Output: {2,4,21,33,55}

b) Write a function that declares an array of 256 doubles and initializes each element in the array to have a value equal to half of the index of that element. That is, the value at index 0 should be 0.0, the value at index 1 should be 0.5, the value at index 2 should be 1.0, and so on. your function must be called in the main. Also, declaring array and the size must be using heap.

In: Computer Science

C++ code: Write a program that randomly generates an integer between 0 and 100, inclusive. The...

C++ code:

Write a program that randomly generates an integer between 0 and 100, inclusive. The program prompts the user to enter a number continuously until the number matches the randomly generated number. For each user input, the program tells the user whether the input is too low or too high, so the user can choose the next input intelligently. Here is a sample run:

In: Computer Science

Case Study 1: Securing your home computer You just purchased a brand new computer for your...

Case Study 1: Securing your home computer
You just purchased a brand new computer for your home environment. It comes with the latest operating system, Internet connectivity and all accessories to complete your home office and school activities. You also have an Internet Service Provider where you can easily use the existing network to connect to the Internet and to perform some online banking.
Describe the steps you plan to go through to ensure this new computer system remains as secure as possible. Be sure to discuss the details of firewall settings you plan to implement, browser privacy and security settings, and recommended software (e.g., Anti-virus and others) you will install. Also, describe your password strength policy you plan to adopt, and what you envision to do to ensure your online banking site is encrypted and uses the proper certificates.
Discussion of operating system patches and application updates should also be included. As you discuss these steps, be sure to justify your decisions bringing in possible issues if these steps are not followed. You can discuss this for a specific type of computer (e.g. MAC or PC) to make the scenario more appropriate for your environment.

In: Computer Science

Use the web or other resources to research at least two criminal or civil cases in...

Use the web or other resources to research at least two criminal or civil cases in which  recovered files played a significant role in how the case was resolved.

Need 300 words Please don't write already existing chegg anw

In: Computer Science

Suppose that the file inData.txt contains the following data: 10.20 5.35 15.6 Randy Gill 31 18500...

Suppose that the file inData.txt contains the following data:

10.20 5.35

15.6

Randy Gill 31

18500 3.5

A

The numbers in the first line represent the length and width, respectively, of a rectangle. The number in the second line represents the radius of a circle. The third line contains the first name, last name, and the age of a person. The first number in the fourth line is the savings account balance at the beginning of the month, and the second number is the interest rate per year. (Assume that π = 3.1416.) The fifth line contains an uppercase letter between A and Y (inclusive). Write statements so that after the program executes, the contents of the file outData.txt are as shown below. If necessary, declare additional variables. Your statements should be general enough so that if the content of the input file changes and the program is run again (without editing and recompiling), it outputs the appropriate results.

Rectangle:

Length = 10.20, width = 5.35, area = 54.57, parameter = 31.10

Circle:

Radius = 15.60, area = 764.54, circumference = 98.02

Name: Randy Gill, age: 31

Beginning balance = $18500.00, interest rate = 3.50

Balance at the end of the month = $18553.96

The character that comes after A in the ASCII set is B


In: Computer Science