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 program with a function that accepts a string as an argument and returns the number of vowels that the string contains. The application should have another function that accepts a string as an argument and returns the number of consonants that the string contains.

The application should let the user enter a string and should display the number of vowels and the number of consonants it contains.

Sample output:

Enter a string: california

The string you entered includes 5 vowels and 5 consonants



Write a function called swap_pairs that accepts a string as a parameter and returns that string with each pair of adjacent letters reversed. If the string has an odd number of letters, the last letter is unchanged. For example, the call swap_pairs('example') should return 'xemalpe' and the call swap_pairs('hello there') should return 'ehll ohtree'.

Sample output for two separate runs:

example -> xemaple

hello there -> ehll hotree




Write a function called repl that accepts a string and a number of repetitions as parameters and returns the string concatenated that many times. For example, the call repl('hello', 3) should return 'hellohellohello'. If the number of repetitions is zero or less, the function should return an empty string. Do not use the string * operator in your solution; use the concatenation operator.

Sample output:

hello -> hellohellohello



Theory/Algorithm


Question 4

4.1.1 Students in Computer Science would like to understand the concept of Ohm’s law. You

are required to write an application that will allow them to calculate the relation

between Voltage, Current and Resistance using the formulas below.

V = IR

Current (I) = V/R

Resistance= V/I

(where I is the current, V - Voltage and R is the resistance)

4.1.1 Write a program that will assist the students:

4.1.2 Create a C++ source file called OLaw and save it in a file called OLaw.cpp.

4.2 Create the following functions:

4.2.1 calcVoltage() This function must calculate the voltage in a circuit using the

information given above.4.2.2 calcCurrent() This function must calculate the current charge using the information

given above.4.2.3 calcResistance() This function must calculate the resistance of the flow using the

information given above.4.2.4 main() NB: The functions must be implemented above the main.

Add all necessary pre-processor directives.

 Declare all constants and necessary variables.

 Prompt the user for the calculation he/she would like to see

(I/I, V/v, R/r)(See Figure 4.1).

 Based on the option selected by the user

o The user must be prompted for the related data as

shown in Figure 4.2 – Figure 4.4.

o The program must then calculate the related

measurements based on the option by calling the

correct function.

o Display the desired measurement.

 If an invalid option is selected an appropriate error message

must be displayed, see Figure 4.5.

NB: Use a switch for the selection

o This process must be repeated until there no calculations to

perform (N/n).4.3 Rewrite 4.2 as follows:

4.3.1

4.4 Create a C++ source file called OLaw2 and save it in a file called OLaw2.cpp.

Create the following functions:

4.3.1 calcCicuirt() This function must calculate the voltage, current and the resistance

in a circuit using the information given above.4.3.2 getInput() This function will prompt the user for the required input as indicated

in Figure 4.1.4.3.3 main() NB: The functions must be implemented below the main.

Add all necessary pre-processor directives.

 Declare all constants and necessary variables.

 Prompt the user for the input values by calling the correct

function.

 The program must then calculate the required

measurements by calling the correct function.

 Display the desired measurement.


Question 5

A student in Programming 1 wants to know the surface area and volume of a cylindrical shape.

Figure 5.1: Example of a cylinder

Volume = PI(R^²) x height

Area = 2PI(R^²) x height + 2PI(R^²)

5.1.1 Write a program that will assist the students:

5.1.2Create a C++ source file called Cylinder and save it in a file called Cylinder.cpp.

5.2 Create the following functions:

5.2.1 calcVolume() This function will receive three parameters and it must then calculate

and return the volume of a cylinder using the information given

above.5.2.2 calcArea() This function will receive three parameters and it must then calculate

and return the area of a cylinder using the information given above.5.2.3 main() NB: The functions must be implemented above the main.

Add all necessary pre-processor directives.

 Declare all constants and necessary variables.

 Prompt the user for the height of the cylinder, and the radius of

the base of the cylinder.

 Based on the users option :

o Do the relevant calculations by calling the correct

function.

 Display the results of the desired measurement.

 If an invalid option is selected an appropriate error message

must be displayed, see Figure 5.5.

NB: Use a switch for the selection

o This process must be repeated until there no calculations to

perform (N/n).5.3 Re-write program 5.2.

5.3.1 calcValues() This function will receive four parameters and it must then calculate

and the volume and the area of a cylinder using the information given

above.5.3.2 promptValues() This function will receive three parameters and it must then prompt

the user for the required input as indicated in Figure 5.2.5.3.3 main() NB: The functions must be implemented above the main.

Add all necessary pre-processor directives.

 Declare all constants and necessary variables.

 Prompt the user for the height of the cylinder, and the radius of

the base of the cylinder.

 Calculation the volume and area by calling the correct

function.

 Display the results the volume and area.


Due date: 14 February 2021


This information was first posted in Week 10 and is now due this week.

You are the IT manager of a large corporation. You are planning to use Python to develop statistical models to aid in analyzing your sales data. You are preparing a report for management. Here are the basic requirements for your report:

  • Prepare in APA format
  • Include references
  • Report length: 500 - 700 words
  • Briefly describe your company
  • Briefly describe Python
  • Give overview of Machine Learning
  • Report on:'
  • Implementation plans
  • Technical training
  • Python libraries required
  • How Python will be used
  • Types of reports that will be produced

1 Write an assembly program for division of two eight bit no. at 4000H=2CH and 4001H=30H and save result at 4002H=quotient and 4003H= remainder.


Senerio:

ATM (Automated Teller Machine) machines are electronic outlets that allow customers to do their basic transactions without interaction of bank’s representative. While programming this ATM in C++, We have created a class named CUSTOMER which stores customer data (i.e. name, NIC, age, address, account balance and transaction history etc.). There is a friend function that wants to access some private information of the class.

Question:


Being a C++ developer, analyze the whole scenario, what do you think, does a friend function contradict the rules of Encapsulation?


Note:

Give your opinion in yes or no with strong reasons.

 Use your program to find the 200-point DFT of the following sequences:

(i) x(n) = 2cos(2πn/10) + cos(2πn/5)

(ii) x(n) = n

Plot the magnitude response of these sequences. The horizontal axis must be scaled appropriately to represent the interval (0, π). Also Comment on the validity of your results.


Write a menu driven program for the following operations on array for 10 elements:

a) display max number from the array

b) display min number from the array

c) display sec max number from the array

d) display sec min number from the array

e) sort the data

f) search the data 

g) display count of prime numbers

h) display count of perfect numbers

i) display max digit from each number 

j) display sum of digits upto one digit for each number


Write a menu driven program for the following operations using loop concept without array: 

a) series of prime numbers from 1 to 1000

b) series of perfect numbers from 1 to 1000

c) series of Armstrong numbers from 1 to 10000

d) range is given by user, after that display count of digits of each number

e) range is given by user, after that display sum of digits of each number

f) range is given by user, after that display max perfect number from that range


LATEST TUTORIALS
APPROVED BY CLIENTS