Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Write a function named "sum_from_to" that takes two integer arguments, call them "first" and "last", and returns as its value the sum of all the integers between first and last inclusive. Thus, for example:


cout << sum_from_to(4,7) << endl;  //will print 22 because 4+5+6+7 = 22

cout << sum_from_to(-3,1) << endl; //will print -5 'cause (-3)+(-2)+(-1)+0 +1 = -5

cout << sum_from_to(7,9) << endl;  //will print 22 because 7+8+9 = 24

cout << sum_from_to(9,9) << endl;  //will print 9

Write a Python program that solves the travelling salesperson problem.


Sample output:

Input: cost for every path:

Cost from 1-2: 10

Cost from 1-3: 15

Cost from 1-4: 20

Cost from 2-3: 35

Cost from 2-4: 25

Cost from 3-4: 30


Output:

Optimal Route: 12431

Total Path Cost: 80




Write a program that allows the user to enter students’ names followed by their test scores and

outputs the following information (assume that maximum number of students is 50). Note you will

need to make use of an array.

a. The average score.

b. Names of all students whose test scores are below the average, with an appropriate

message.

c. Highest test score and the name of all students having the highest score. 


Consider the following Job Completion problem: Given n workers and m jobs, such that each worker has a list of jobs that he can do. Decide if there is an assignment such that every job gets assigned to a worker who can do the job, assuming that each worker is given at most one job. Design an efficient algorithm for the problem. Analyze your algorithm. 


// PLACE YOUR NAME HERE 

#include 

using namespace std; 

int main() 

char letter = 'a'; 

while (letter != 'x') 

{ cout << "Please enter a letter" << endl; cin >> letter; 

cout << "The letter you entered is " << letter << endl; 

return 0;

Exercise 2: Add to the code so that the program is more user friendly. 

Exercise 3: How would this code affect the execution of the program if the while loop is replaced by a do-while loop? Try it and see. 


Illustrating working of public and private class

Create a class in C++ and name it room. Declare its data members: (length, breadth and height) inside the class as

private

Create a function to initialize the private variables (void getData)

Create two methods/functions called calculateArea (that returns: length * breadth) and calculateVolume (that returns: length * breadth * height ).

Create object of the room class

Pass the values of the private variables as arguments Display the calculated Area of room and Volume of room.

 2


Illustrating working of class ad objects

Create a class in C++ and name it room. Declare some data members: (length, breadth and height) inside the class.

Create two methods/functions called calculateArea (that returns: length * breadth) and calculateVolume (that returns: length * breadth * height ).

Create object of the room class.

Assign values to the data members declared

Display the calculated Area of room and Volume of room.



Write a python program that takes balance of a user’s account as input. It should then ask the user how much amount he\she wants to withdraw from his\her account. The program should take this amount as input and deduct from the balance. Similarly, it should ask the user how much amount he\she wants to deposit in his\her account. It should take this amount as input and add to the balance. The program shall display the new balance after amount has been withdrawn and deposited.

Note: Your program should have all necessary checks on the transactions. Display a menu to the user to let him\her choose between different available options.


// PLACE YOUR NAME HERE

#include

using namespace std;

int main()

{

char letter = 'a';

while (letter != 'x')

{ cout << "Please enter a letter" << endl; cin >> letter;

cout << "The letter you entered is " << letter << endl;

}

return 0;

}

Exercise 2: Add to the code so that the program is more user friendly.

Exercise 3: How would this code affect the execution of the program if the while loop is replaced by a do-while loop? Try it and see. 


A company that wants to send data over the Internet has asked you to write a program in Python that will encrypt it so that it may be transmitted more securely. All the data is transmitted as four-digit integers. Your application should read a four-digit integer entered by the user and encrypt it as follows:

a)     Replace each digit with the result of adding 6 to the digit and getting the remainder after dividing the new value by 10.

b)    Then swap the first digit with the third and swap the second digit with the fourth. Then print the encrypted integer. Write a separate application (in Python) that inputs an encrypted four-digit integer and decrypts it (by reversing the encryption scheme) to form the original number.


LATEST TUTORIALS
APPROVED BY CLIENTS