1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mart [117]
3 years ago
13

Use the variables k and total to write a while loop that computes the sum of the squares of the first 50 counting numbers, and a

ssociates that value with total. Thus your code should associate 1*1 2*2 3*3 ... 49*49 50*50 with total. Use no variables other than k and total.
Computers and Technology
1 answer:
Vikentia [17]3 years ago
6 0

Answer:

total=0

def calcsumnumsquare(k,total):

   while k>=1:

       total+=int(k)*int(k)

       k-=1

   return total

print(calcsumnumsquare(4,0))

Explanation:

The program required is written above. It uses only two variables k and total as mentioned in the question. And the total is initially set to 9, and then its value is incremented by the square of each k during each loop established by while loop. And finally, when k=1, the output is returned. And we have printed the return value using print.

You might be interested in
In order for the image tag in an HTML file to function properly, the file named square.png must be located where?
andrey2020 [161]
A is wrong because a folder can have any name.
B is wrong because not all folders of a web server are exposed to the outside, only all folders below the document root.
C sounds good
D is wrong because an image can reside somewhere else as long as you specify the absolute or relative path to it
7 0
3 years ago
Read 2 more answers
Lan is working on a project report that will go through multiple rounds of
Levart [38]
Its either D or A but im pretty sure its D??
8 0
3 years ago
Suppose that we have a set of activities to schedule among a large number of lecture halls, where any activity can take place in
laiz [17]

Answer:

By Using the Greedy- Activity- Selection algorithm

Explanation:

The Greedy- Activity- Selection algorithm in this case involves

First finding a maximum size set S1, of compatible activities from S for the first lecture hall.

Then using it again to find a maximum size set S2 of compatible activities from S - S1 for the second hall.

This is repeated till all the activities are assigned.

It requires θ(n2) time in its worse .

8 0
3 years ago
In this lab, you will build a system for package delivery services that provides different shipping options with specific price.
Alex73 [517]

Answer:

See explaination

Explanation:

#include <iostream>

#include <string.h>

using namespace st d;

class Package

{

protected:

//sender properities

char sname[10],saddress[50],scity[20],sstate[20];

long int szip;

//Receiver properities

char rname[10],raddress[50],rcity[20],rstate[20];

long int rzip;

//additonal datamembers

float weight,cost;

public:

Package() //Default constructor

{

strcpy(sname,"");strcpy(saddress,"");strcpy(scity,"");

strcpy(sstate,"");szip=0;

strcpy(rname,"");strcpy(raddress,"");strcpy(rcity,"");

strcpy(rstate,"");rzip=0;

weight=cost=0;

}

Package(char sn[10],char sa[50],char sc[20],char ss[20],long int sz,char rn[10],char ra[50],char rc[20],char rs[20],long int rz,float w,float c) //Constructor with parameter

{

strcpy(sname,sn);strcpy(saddress,sa);strcpy(scity,sc); //copying each parameter value to data member

strcpy(sstate,ss);szip=0;

strcpy(rname,rn);strcpy(raddress,ra);strcpy(rcity,rc);

strcpy(rstate,rs);rzip=0;

weight=w;cost=c;

}

float calculateCost() //calculating cost

{

return weight*cost;

}

};

class TwoDayPackage:public Package //Inheritance

{

float flatfee;

public:

TwoDayPackage(char sn[10],char sa[50],char sc[20],char ss[20],long int sz,char rn[10],char ra[50],char rc[20],char rs[20],long int rz,float w,float c,float ff) //Constructor with parameter

{

Package(sn,sa,sc,ss,sz,rn,ra,rc,rs,rz,w,c); //calling super class constructor

flatfee=ff; //copy last parameter

}

float calculateCost() //redefined calculateCost function

{

return (weight*cost)+flatfee; //return total cost

}

};

class OverNightPackage:public Package //Inheritance

{

float addfee;

public:

OverNightPackage(char sn[10],char sa[50],char sc[20],char ss[20],long int sz,char rn[10],char ra[50],char rc[20],char rs[20],long int rz,float w,float c,float a f) //constructor with parameter

{

Package(sn,sa,sc,ss,sz,rn,ra,rc,rs,rz,w,c); //calling super class constructor

addfee=a f; //copy last parameter

}

float calculateCost() //redefined calculateCost function

{

return (weight*cost)+addfee; //calculating total cost

}

};

int main()

{

Package package1("lou brown","1 main st","boston","ma",11111,"mary smith","7 elm st","new york","ny",22222,8.5,0.5); //creating objects

TwoDayPackage package2("lisa klein", "5 broadway", "somerville", "ma", 33333, "bob george", "21 pine rd", "cambridge", "ma", 44444, 10.5, .65, 2.0 );

OverNightPackage package3 ("ed lewis", "2 oak st", "boston", "ma", 55555, "don kelly", "9 main st", "denver", "co", 66666, 12.25, .7, .25 );

cout<<"\nPackage Cost : "<<package1.calculateCost(); //calling each cost

cout<<"\nTwoDay Package Cost : "<<package2.calculateCost();

cout<<"\nOvernight Package Cost : "<<package3.calculateCost();

return 0;

}

8 0
3 years ago
. In the BorderLayout class, what are NORTH, SOUTH, EAST, WEST, and CENTER?
ycow [4]

Answer:

A BorderLayout corresponds to a layout type where the components are organized along geographical directions represented by NORTH, SOUTH, EAST, WEST, and CENTER.

Explanation:

The layout class is awt determines the actual placement of components in the user interface. BorderLayout is a layout where the components are organized along geographical directions represented by NORTH, SOUTH, EAST, WEST, and CENTER. For example:

Panel p = new Panel();

p.setLayout(new BorderLayout());

p.add(new TextArea(), BorderLayout.CENTER);

p.add(new Button("Close"), BorderLayout.SOUTH);

This code segment will add a textarea at the CENTER of the interface and a button 'Close' towards the SOUTH.

8 0
2 years ago
Other questions:
  • Compare the logical link control and the media access control. Which of the following is a correct statement?
    7·2 answers
  • 4. Who developed the first design technology program which had a
    12·1 answer
  • 6) RAM, 5 main memory<br>which storage conbe used<br>as permanent storage<br>Rom<br>a) R<br>)​
    8·2 answers
  • Most hard drives are divided into sectors of 512 bytes each. Our disk has a size of 16 GB. Fill in the blank to calculate how ma
    9·1 answer
  • How does leadership play a role in IT management? How does leadership need to be aligned to the company’s goals for IT managemen
    9·1 answer
  • Using existing algorithms as building blocks for new algorithms has all the following benefits EXCEPT
    12·1 answer
  • Write short notes about monitor printer and speaker​
    14·2 answers
  • I NEED HELP, DO ASAP <br> Why do you have to adjust toys for different ages?
    11·2 answers
  • true or false? multimedia components such as audio and video do not significantly contribute to increased computer network traff
    15·1 answer
  • 70 point Brainlist to best answer
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!