Intro. to Programming Workshop - 5

Welcome back to the Intro. to Programming Workshops! This week's workshop will focus on problem solving!
The PokeVentures game code now has a new home on GitHub, you can find the new home in the resources section below!
The latest edition now includes multiplayer and in-game chat!

Resources

Summary

Question

Write a program that calculates the integral (area under graph) for f(x)=x^3 that receives input for the interval (a, b) and number of sub-intervals (n).
The program should also ask for the method for calculating the integral out of the following options:

Additionally, note the following:

  • You must implement both methods in your program
  • You may assume that all input is valid
  • a and b are of type double
  • n is of type int

Examples

Scenario One:

Please enter the interval (a, b) and sub-intervals (n):  
3.0 5.0 12  
Type 'r' for Rectangle method or 't' for Trapezoidal method:  
t  
The answer is 136.1111  

Scenario Two:

Please enter the interval (a, b) and sub-intervals (n):  
0 144 1  
Type 'r' for Rectangle method or 't' for Trapezoidal method:  
r  
The answer is 0  

Solutions

Located under the Resources heading!