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

The following program fragment is supposed to count the sum of the numbers divisible by 7 read until the number -1 is encountered (upon which the program exits after printing the value of the sum). For example, if the input is "1 4 7 2 42 -1", the output should be 49.


IMPORTANT NOTE -> all answers should be without semicolons and any spaces. special requests in these cases won’t be considered.


int req_sum = 0;

int x=0;

while(B1){

cin >> x;


if (x%7==0) B2;


}


cout<<req_sum<<endl;


int x, i;

x = 28;

int fsum = 0;

for(int i=1; i<=x; i++){

if( x%i == 0 )

fsum += i ;

}

cout<<fsum<<endl;

if ( fsum == 2*x )

cout<<1<<endl;

else

cout<<0<<endl;

1.If the program in the previous question is modified to read 'n' from keyboard (instead of assigning a constant inside the program). In general, what does such a modified program print?


NOTE - Perfect number is a positive integer that is equal to the sum of its proper divisors.


(a) The program prints the sum of proper divisors of n, followed by 1 if it is a perfect number and 0 if it is not.

(b)The program prints the sum of all divisors of n, followed by 0 if it is a perfect number and 1 if it is not.

(c) The program prints the sum of proper divisors of n, followed by 0 if it is a perfect number and 1 if it is not.

(d) The program prints the sum of all divisors of n, followed by 1 if it is a perfect number and 0 if it is not.


Write a Java method to check whether a string is a valid password. Each character must be stored in a character array


Password rules:


A password must have at least ten characters.


A password consists of only letters and digits.


A password must contain at least two digits.


Expected Output:


Input a password (You are agreeing to the above Terms and Conditions.): abcd1234


Password is valid: abcd1234



1. Create a class CIRCUIT with the following public attributes: total resistance, total  voltage and total current. Assign proper variable type and name for each  attribute. Total voltage must be static. (static double variablename) 

2. Create a method setVoltageSource() of circuit class to set a constant value of  voltage to 24 volts. This value is true to all types of connection thus; it should be a  static method.  

3. Create a public method getTotalCurrent() to compute and display total current  in 2 decimal values. Total current is equal to the ratio of voltage and total  resistance. (I = V/R) 

4. Create a child class of class CIRCUITS named Series and Parallel 

5. Each class must have an integer attribute named numres. This variable holds the  number of resistors in a circuit and will be used for display only.  

6. In series class, create a public method named computeTotalresistance(double  r1, double r2). This method is used to accept two resistance values and  computes the total resistance of a series connection with 2 resistors.  

Total resistance is the summation of the two resistance values. Also, it sets numres  equal to 2. 

NOTE: store computed total resistance to the total resistance attribute of the  parent class. A child class can use attributes and methods of a parent class  (Inheritance). 

7. Overload the method from the previous item (7) that accepts 3 resistance values  and computes the total resistance of a series connection with 3 resistors. Total  resistance is the summation of the three resistance values. Also, it sets numres  equal to 3. 


NOTE: store computed total resistance to the total resistance attribute of the  parent class. A child class can use attributes and methods of a parent class  (Inheritance). 

8. Perform item 7 and 8 in parallel class.  

a. Total resistance 2 resistor = 1/(1/resistor1 + 1/resistor2) 

b. Total resistance 3 resistor = 1/(1/resistor1 + 1/resistor2 + 1/resistor3) 

Set value of numres accordingly.


9. Add new public methods in each class (series and parallel) named disType() to  display the type of circuit connection and number of resistor (numres). See test  case below. 

10. Implement encapsulation by setting up the total resistance attribute in both  series and parallel class to private and creating public class to allow other class  to access the total resistance value. This is an example of a read only function  when using encapsulation. 

11. Create an interface class called DisplayCircuitType. It contains an abstract  method of disType(). Modify the series class and parallel class to implement this  interface class. A subclass (extends) can be also implement interface  (implements). Syntax: public class childclassname extends parentclassname  implements interfaceclassname  

12. Complete the program with the following steps: 

a. Use scanner to enter 3 values (resistor values). Create 3 variables to store  each inputs 

b. Create 2 objects of Series Class and 2 objects of Parallel Class 

c. Call setvoltage() to set uniform voltage 

d. Work on with the first object of Series class with 2 resistors. Call  

computeTotalResistance and disType methods. Print the value of  

getTotalResistance. Call getTotalCurrent. 

Note: In calling computeTotalResistance method you have to indicate  number of parameters. 

e. Work on with the first object of Series class with 2 resistors. Call  

computeTotalResistance and disType methods. Print the value of  

getTotalResistance. Call getTotalCurrent. 

Note: In calling computeTotalResistance method you have to indicate  number of parameters. 

f. Test the program for the first circuit. If it gives the correct answer, work on  the other circuits.




Each week a builder makes an order of doors from a supplier. The doors normally cost $60 each, but the supplier gives a 10% discount for any order of 30 or more doors. The orders for the first 8 weeks of the year are given in the vector: orders = [20 40 15 30 25 45 10 35]

  1. (a) Write a MATLAB program using a for loop and if statement to find the total cost of the doors ordered.
  2. (b) Extend your program using the find command to find which weeks the builder obtained a discount. 

The purpose of the physical layer is to transport bits from one machine to another. Various guided media can be used for the actual transmission. Each one has its own features in terms of bandwidth, delay, cost, and ease of installation and maintenance. List various types of guided media discuss its features and uses in real world.


A salesman wants to travel among 4 or n cities. He wishes to visit maximum or all cities in one day. The order of visiting different cities is not important, but his point of consideration is to minimize distance travelled. In a map this scenario can be described in this way; Cities are represented by nodes, and distance is represented as edges.

Suppose he starts travel from source city ‘A’, visit different cities in the following ways:

A->C->B->D

A->D->C->B

A->B->D->C

you have to choose a suitable algorithm from the following list of algorithms which you think is the best algorithm for the salesman to cover maximum cities by traveling minimum distance.

  • Prim''s Algorithm
  • Dijkstra''s Algorithm
  • Bellman-Ford Algorithm
  • Floyed-Warshall Algorithm
  • Johnson''s Algorithm

Create a java program that would compute and display the total mobile services fee incurred by a customer. Mobile services include text messages, calls in minutes and mobile data usage in megabytes.

Each customer was given a customer ID that would indicate the type of mobile plan he/she availed.

PLAN A:

-Customer ID ending with 0. Loyal member has 5 digits and above ID number.

-monthly fixed rate of P500.00

-allows free text messaging up to 250 messages. Beyond that, each message is charged 90 centavos.

-All-net calls up to 60 mins. Exceeding minutes applies P5/min.

-P5/MB. Free use of mobile data up to 80MB.

-20% discount from the total charge for Loyal member.

PLAN B:

-Customer ID ending with 5. Loyal member has 5 digits and above ID number.

-monthly fixed rate of P750.00

-allows free text messaging of up to 500 messages. Beyond that, each message is charged 70 centavos.

-All-net calls up to 120 mins. Exceeding minutes applies P5/min.

-P5/MB. Free use of mobile data up to 100MB.

-40% discount from the total charge.

PLAN C:

-Customer ID ending with 2. Loyal member has 5 digits and above ID number.

-monthly fixed rate of P1,200.00

-allows free text messaging of up to 1,000 messages. Beyond that, each message is charged 50 centavos.

-All-net calls up to 240 mins. Exceeding minutes applies P5/min.

-P5/MB. Free use of mobile data up to 500MB.

-60% discount from the total charge.


Input:

The first line of the input file will contain a single integer N that represents the

Customer ID number. Next line consists of 3 integer T, C and D, separated by commas (,). T is the total number of text messages; C is the total number of calls in minutes and D is the total data usage in MB.


Output:

The total mobile fee of the customer applying all charges given in the description and discounts if applicable. In addition, the program must also display an offer to upgrade the plan type for customers who have exceeded their monthly fixed rate by 200%.

Ex. Plan A

–Total bill of P1,860.00 means the customer exceeded by P1,360.00 or 272% from his/her monthly fixed rate of P500 (P1,860-500=1,360).






Write a C++ program that declare a structure “Country” having cid, cname as a members. Declare another structure “Cities” having member’s citiy_name, male population, and female population also contains country structure as a reference. Input the record of 4 cities in structure variable and passes them to a function as an argument. The function will display all record of city having highest male and female population.


Suppose he starts travel from source city ‘A’, visit different cities in the following ways:

  • A à C à B à D
  • A à D à C à B
  • A à B à D à C

Considering the above scenario, you have to choose a suitable algorithm from the following list of algorithms which you think is the best algorithm for the salesman to cover maximum cities by traveling minimum distance.

  • Prim''s Algorithm
  • Dijkstra''s Algorithm
  • Bellman-Ford Algorithm
  • Floyed-Warshall Algorithm
  • Johnson''s Algorithm
LATEST TUTORIALS
APPROVED BY CLIENTS