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

Temperature Conversion

You are given the temperature T of an object in one of Celsius, Fahrenheit, and Kelvin scales.

Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.

Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.

Formula to convert from Kelvin K to Celsius C is C = K - 273.

Here "C", "F", "K" represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively.

The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space.

The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places.Input


The first line of the input contain a temperature Value in one of Celsius, Fahrenheit, and Kelvin scales.Output


The first line of output should contain the Celsius value and the unit of the Celsius without any space.

The second line of output should contain the Fahrenheit value and the unit of the Fahrenheit without any space.

The third line of output should contain the Kelvin value and the unit of the Kelvin without any space.Explanation


For example, if the given temperature Value is 25C then Celsius value is 25.0C, Fahrenheit value is 77.0F, and Kelvin value is 298.0K.

Sample Input 1

25C

Sample Output 1

25.0C

77.0F

298.0K

Sample Input 2

37.5F

Sample Output 2

3.06C

37.5F

276.06K


Given polynomial, write a program that prints polynomial in Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0 format.


Input


The first line contains a single integer N.

Next N lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes coefficient of Pi.


Output


Print the polynomial in the format Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is coefficient, and C0 is constant. There will be space before and after the plus or minus sign.

If the coefficient is zero, then don't print the term.

If the term with the highest degree is negative, the term should represent -Cix^Pi.

For the term where power is 1, represent it as C1x instead of C1x^1.

If the polynomial degree is zero and the constant term is also zero, then print 0 to represent the polynomial.

For term Cix^Pi, if the coefficient of the term Ci is 1, print x^Pi instead of 1x^Pi.


Constraints


N <= 100

0 <= Pi < 1000

-1000 <= Ci <= 1000


Sample Input


5

0 2

1 3

2 1

4 7

3 6


Output:


7x^4 + 6x^3 + x^2 + 3x + 2

You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on matrix A.


Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.


Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.

After the update, all the previous rotation operations have to be applied to the updated initial matrix.


Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A.


Input:


The first line contains a single integer N.

Next N lines contain N space-separated integers Aij (i - index of the row, j - index of the column).

Next lines contain various operations on the array. Each operation on each line (Beginning either with R, U or Q).

-1 will represent the end of input.


Output:


For each Query operation print the element present at row index K and column index L of the matrix in its current state.


Sample Input:


2

5 6

7 8

R 90

Q 0 1

R 270

Q 1 1

R 180

U 0 0 4

Q 0 0

-1


Sample Output:


5
8
8

Given an MxN matrix, write a program to print all Anti-Diagonals elements of the matrix


Input:


The first line of input will contain M, N values separated by space.


The second line will contain matrix A of dimensions MxN.


Output:


The output should contain anti-diagonal elements separated by a line.


Sample Input 1:

2 3

1 5 5

2 7 8


Output:


1
5 2
5 7
8


Sample Input 2:


3 4

1 2 3 4

5 6 7 8

9 10 11 12


Output:


1
2 5
3 6 9
4 7 10
8 11
12





·       A client (a person who wants a program developed) who owns a car rental company wants a program developed that will estimate the litres of gas needed to drive a car a given distance in kilometers on a highway for a road-trip. Currently staff at the rental desk need to ask the customer the estimated mileage the car will be driven on the highway, they then need to look up the fuel efficiency of the car to be rented and use that within the math needed to determine the amount of gasoline in litres the customer will need for their road-trip. A typical fuel economy for the rental company's cars is 6.8L/100Km, most customers have round trips of 900Km on the highway, for example from Ottawa to Toronto. The program should allow the entry of the distance to drive, the litres per 100Km for efficiency, and output the Litres of gasoline needed, rounded up to a whole number when producing the result.

·       You would only need to input 6.8 for the efficiency, work with 100Km internally in the program as part of your math.

·       Write out briefly how you would do each step, as if you were the staff member. Including examples of math calculations you would perform either by hand, or with the assistance of a calculator.

·       Type this into your MS Word document as part of your submission.



2) Develop and Describe an Algorithm including Classes

·       Determine what objects, the properties of the objects, and behaviors would be required for an object oriented program, start with simple UML class diagrams and as you work out more details document the design with a detailed UML class diagram.

·       Write pseudo-code as the basis of your algorithm, as well as create a flowchart. You should reference the lecture notes, as well as your textbook by Joyce Farrell [2] as learning resources for this part of the assignment.

·       You should show object instantiation in the flowchart as variable declarations, then use method calls to methods. Note, you are not required to document get/set accessor, mutator methods in your algorithm or flowchart in detailed step-by-step, only method main and any method(s) that perform math calculations.

·       You may hand-draw the flowchart and UML class diagram for this assignment instead of using software, just use a ruler and print legibly.

·       Alternatively a software program like Diagrams.net can be used for flowchart while a software program like UMLet can be used to create the UML class diagrams. Other programs like MS Visio, or even MS Word can be used instead.

·       Your name as author must appear within any diagrams you create.

·       If working on paper either scan the diagram into your computer, or use a cell phone to take a picture and email it to yourself. Both your pseudocode and flowchart should be placed into your MS Word document, the pseudocode as text while the flowchart should be an image. Note: The pseudocode and flowchart should document the exact same algorithm.

·       Your UML diagram provides a high-level view of the Structure of the objects, while the pseudocode and flowcharts provide the basis for the sequential logic within method main.



3) Test Algorithm with Simple Inputs

·       As per the lecture notes, use a table within your MS Word document to test the algorithm. Consider picking numbers that might be expected as input and work through the algorithm documenting expected outputs, you may use a calculator.

·       If there is a problem with the algorithm based on this desk-check correct the pseudocode and flowchart, UML class diagram(s) and repeat this step again.


4) Translate the Algorithm into Java

·       You are to use the Eclipse IDE to create your Java program, use a project name like Assignment 02.

·       Don’t forget to comment your code files, with the expected code header.

·       You are not required to copy and paste code into the MS Word document, however your .java file(s) must be submitted.



5a) Compile and Run Your Program

·       Compile and run your program, using your documented test values.

·       Take a screen shot of Command prompt window, or a rectangular selection of the Eclipse Console View depending on your development environment, ensure your name as output by the program is captured in the image.



5b) Test Your Program

·       Re-create your testing table from step 3 in this section, but document what the program outputs are, do they match expectations?

·       Test with some invalid inputs, and document what happens. Note that some input will crash your program, this is okay as you may not know how to fix this at this point in the course. Document what the error messages are in your test plan. Suggested invalid tests: enter a String instead of a number.


The fact that most metals expand when heated and contract when cooled has serious implications when the dimensions of a piece of laboratory equipment are critical to an experiment. A typical aluminum bar that is w cm wide at 70 degrees Fahrenheit will be


x =w + (t – 70) x 10-4


cm wide at a nearby temperature t. Write a program that prompts the user for the standard width of a bar at 70 degrees Fahrenheit and for a tolerance for width variation. Then display a table like the one below indicating the bar’s width at temperatures from 60 degrees to 85 degrees in one degree intervals and marking with a star (*) the temperatures at which the bar’s width is within the tolerance.


2. Create another class Report holding a main function. This class will ask the user for type of data to be displayed like 1. Medical report 2. Grocery purchase bill 3. Electricity bill 4. Exit Once the choice is selected, write the code for invoking appropriate methods of the respective class for reading the details of three household and display the information.


1. Implement the following using java:

Consider three classes named Diagnosis, Grocery and Electricity containing variables for medical report of the patient, grocery bill, electricity and methods for getting and displaying the details from the user.

a. Diagnosis class can have instance variables for patient id, name, symptoms, COVID_Status and functions for reading these values from the user and displaying it.

b. Grocery class can have instance variables required for computing a monthly expense on grocery such as Monthly_budget, No_of_times_grocery_purchased, Average_ expense_on_each_purchase, and functions for reading these values and computing the Amount_spent_on_grocery and percentage_of_budget_alloted.

c. Electricity class can contain the instance variables such as amount of units consumed every month and electricity bill for every month and average electricity consumption for every day. It can have functions for reading the values from the user and computing the electricity bill and consumption/month. 


Create another class Report holding a main function. This class will ask the user for type of data to be displayed like 1. Medical report 2. Grocery purchase bill 3. Electricity bill 4. Exit Once the choice is selected, write the code for invoking appropriate methods of the respective class for reading the details of three household and display the information in java program


1 Study the following descriptions and write only the statements to achieve the required

objectives in both algorithm and C++ syntax.

2.1.1 The array called quantity has 20 elements. Write statements that will help in counting

how many of these elements have a value of less than 50. Also determine the sum of

the values that are more than or equal to 50. Display these 2 answers.

2.1.2 The array called itemPrice has 150 elements. Write the statements to determine and

display the highest price. If there is more than one item with this price, the number of

items must also be displayed.



LATEST TUTORIALS
APPROVED BY CLIENTS