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

  • Create a folder named LastName_FirstName (ex. Reyes_Mark) in your local drive.
  • Create a project named LabExer2. Set the project location to your own folder.
  • Construct a simple purchasing program based on the UML Class Diagram below.

LabExer2

  • itemName: String
  • itemPrice: double
  • itemQuantity: int
  • amountDue: double

+ setItemName(String newItemName): void

+ setTotalCost (int quantity, double price): void

+ getItemName(): String

+ getTotalCost(): double

+ readInput(): void

+ writeOutput(): void

Note: The readInput() method will be used to accept user input through the Scanner class. This is done by:

  • Writing import java.util.*; on top of the code, before the line for the class name
  • Instantiating an object of the Scanner class, Scanner s = new Scanner (System.in);
  • Storing the input to the variable name based on data type For String: s.nextLine()

For int: s.nextInt()

For double: s.nextDouble()


You are purchasing 3 bag(s) at 1,745.5 each.


For the below mentioned pseudo code (i) and pseudocode (ii), write the equivalent assembly code (mnemonics) in zero, one , two, three address instruction format for swapping the value of two variables a and b.


// pseudo Code(i)

 

Void Swap(int a , int b)

{

int temp;

temp=a

a=b;

b= temp;

}


// pseudo  Code(ii)

/*Assume the address of variable a and b is stored in the pointer variable *x and *y. */

 

Void Swap(int *x , int *y)

{

int temp;

  temp= *x;

  *x=*y;

*y= temp;

}


(i) With taking necessary assumption, find the number of clock cycle that will be required for each case in zero, one, two, three address format for the completion of the program.

(ii) For each case find the number of times refers to memory for the completion of the program.


What is the output of the following code segment?




int i = 5, j = 6, k = 7, n = 3;






cout << i + j * k - kn << endl;




cout << in << endl;

Write a function that takes an array of integers as input and prints the second-maximum difference between any two elements from an array.

The Fibonacci sequence is constructed by adding the last two numbers of the sequence so far to get the next number in the sequence. The first and the second numbers of the sequence are defined as 0 and 1. We get:



0, 1, 1, 2, 3, 5, 8, 13, 21…





Write a function which takes input as a number:



If the given number is a Fibonacci number, print the number



If the given number is NOT a Fibonacci number, print the sum of all odd Fibonacci numbers less than the given number.

write a function that takes an array of integer as output as input and prints the second maximum difference between any two elements from an array 


Suppose you went to a coffee shop and you want to drink some coffee. You


decided to drink n cup of coffee, where n is an integer value greater than


0. Now you have to pay m taka for the first cup of coffee, 2m taka for the


second cup, 3m takas for the third cup, and so on. In other words, you have


to pay i*m taka for the i-th cup of coffee.



Now you have k taka in your pocket. How many takas do you need to borrow


from your friend to buy n cup of coffee?



The first input in the sample input contains the cost of the first cup of


coffee which can be denoted as m. The second input is the number of coffees


you want to drink, n. The third input is k, the initial amount of taka you


have. You have to calculate how much money you have to borrow from your


friend. If you have more or equal amount of money that is needed than print


0.




Plot on the same figure the calculated acceleration and the classification variable ds mapping

against time. Use left side y-axis and a line style to plot the acceleration. Use right side

y-axis to illustrate the driving style classification. Hint: You may use plotyy to complete this

task. Add labels to all axes. Add legend to the figure.


Driving Style: Normal, Acceleration = 0.70 m/s2


Driving Style: Economic, Acceleration = -2.30 m/s2


Driving Style: Economic, Acceleration = 2.31 m/s2


Driving Style: Economic, Acceleration = -3.30 m/s2


Driving Style: Economic, Acceleration = 3.31 m/s2


Driving Style: Agressive, Acceleration = -8.50 m/s2


Ds mapping

NORMAL = 2;

ECONOMIC = 5;

AGGRESSIVE=8;




Create variable ds mapping to store corresponding classification values of 1,2 or 3, which represent different driving style as shown in Table 1. You need to evaluate only the magnitude the of the acceleration/deceleration. If the acceleration value is outside the defined ranges assign 0 as its classification.


Table 1 (4 by 2)


Driving style Economic (1) Normal (2) Aggressive (3)

Acceleration magnitude [m/s2 ] 0.7-2.3 2.31-3.30 3.31-8.5 


Economic (1)

0.7-2.3


Normal (2)

2.31-3.30


Aggressive (3)

3.31-8.5 


Use the battery voltage and current data imported to calculate the battery power P as follows P = UI where P is the battery power [W], U is the battery voltage [V] and I is the battery current [A]


battery voltage in V [Pack Volts]

battery current in A [Pack Amps]


LATEST TUTORIALS
APPROVED BY CLIENTS