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 two functions:

A function named sum which takes two integer values as arguments, and returns their sum.

A main function which asks the user for two integer values, passes the two values to the sum function, then prints the two values and their sum.

The main function then again asks the user for two integer values, passes the two values to the sum function, then prints the two values and their sum.

Test it once, with the values 3 and 4, and then 5 and 49.


You are given an electricity project for the calculation of amount for the consumed electricity units for every one month.

1) For the electricity units (0-200) is 50 paisa per units.

2) For the electricity units (201-400) is 65 paisa per unit. For the first 0-200 consumed units charge is 100 rupees, if the consumer consumed greater than 200 and less than or equal to 400 unit, then for each unit charge is 65 paisa.

3)For the electricity units (401-600) is 80 paisa per unit. For the first 0-400 consumed units charge is 230 rupees, if the consumer consumed greater than 400 unit and less than or equal to 600, then for each unit charge is 80 paisa.

4)For the electricity units above 600, the price for each unit is 80 paisa. For the first 0-600 units charge is 390 rupees, if the consumer consumed greater than 600 unit, then for each unit charge 1.50 paisa.

Case= Test 1

input=

123

100

output=

Electricity Amount to be paid is:50.00

Case= Test 2

input=

124

300

output=

Electricity Amount to be paid is:165.00


Given a positive number, create an array with that number as the size and populate it with the items/names provided. Additionally, the program should print out the longest name in the array.

Sample Run1 

           3

         Apple

          Banana

         Kiwi

Output1: Banana is the longest name


 As a build-up from the previous question, consider 3 possible scenarios of input: A character, number, or word. Your program should then do the following:

  • In case the input is a character it should indicate if it’s a vowel or not
  • when a number is entered then it’s should check if it’s a prime
  • Finally, if a word is entered the system should check if it’s a palindrome or not.

     Sample Run 1                               Sample Run 3

             Enter a character, number or word : c                  Enter a character, number or word : 

             Output 1 : C is not a vowel                                     Output 3 : 7 is a prime number  

Sample Run 2

              Enter a character, number or word: programming

Output 2: Programming is not a palindrome

Using the provided recording and your knowledge from programming 1. Create a program in java that takes in an input from the user and checks whether it’s a number or a word. In case a number is entered the program should print the number to the power 3 and if a word is entered your program should split that word into 2.

Sample Run 1

Enter a number or word: 7

Output 1:

7 to the power 3= 343

Sample Run 2

Enter a number or word: NAMIBIA

Output 2:

The word split in half is : NAMI and BIA 


Why must we check before the call to preorder when implementing as a method, whereas we could check inside the call when implementing as a function?


A certain company plan to give a 10% bonus to each of its employees at the end of every year. If an employee has been working 10/more years at the company, she/he is to get an additional birr 100. Draw a flowchart of an algorithm to calculate and print the bonus for a given employee.




PROGRAM 3 – Times tables




You must write a small application in JAVA that will read in a positive integer and then display the times tables for that number, from 1 to 12.



Your program must




1. Read in the integer as input.




2. Calculate and display the complete times tables up to 12 for that integer.




3. If a zero or any number less is entered, an error message must be displayed and the user must be allowed to input another value.




PROGRAM 2 – Maths Calculator


Write a small application in JAVA that reads in two integers, and then asks the user to type in a character to indicate what calculation must be done with the two numbers, viz:


A to add


S to subtract


M to multiply


D to divide


Display the result of the calculation.



The output of sample runs of the program is given below (the text in bold was typed by the user).


Please use the SAME wording/messages/labels as shown.


Sample execution run 1 Sample execution run 2


Enter the first number: 27


Enter the second number: 9



What would you like to do?


A to add


S to subtract


M to multiply


D to divide



Enter choice: s


27 minus 9 is 18.


Enter the first number: 15


Enter the second number: 0



What would you like to do?


A to add


S to subtract


M to multiply


D to divide



Enter choice: D


**Error** Cannot divide by zero.




PROGRAM 1 – Shopper Calculator


You must write a small application in JAVA that can assist a shopper by calculating the total price of the items that he or she wants to buy and displaying a tillslip-like list of the products, their prices and the total due.


Your program must


1. Read the name and price of five items as input.


2. Calculate the total price for the items.


3. Display all the item names and prices.


4. Display the total due for all items.



LATEST TUTORIALS
APPROVED BY CLIENTS