Question

Define a problem with user input, user output and mathematical computation. Include source code and output....

Define a problem with user input, user output and mathematical computation.
Include source code and output. If no output explain the reason why and what you are going to do make sure it does not happen again aka learning from your mistakes. (JAVA)

Problem:
Pseudocode:
Code:
Output:

Homework Answers

Answer #1

Problem: To find the simple interest using the principal amount given and rate of interest at which it is given and the time period for which it is given.

Psuedo Code:

Taking input from the user for the values, p, r, t
if all values > 0
calculate interest
print the interest
else
return with an error

Following is the JAVA Code for the same.

import java.util.Scanner;

public class SimpleInterest {
   public static void main(String args[]) {
       Scanner scan = new Scanner(System.in);
       System.out.println("-------This is the simple Interest calculator---------");
       System.out.println("Enter the principal Amount, Rate of interest, Time period in years");
       int p = scan.nextInt();
       double r = scan.nextDouble();
       double t = scan.nextDouble();
       if(p>0 && r>0 && t>0) {
           double interest = (p*r*t)/100;
           System.out.println("Interest: " + interest);
           System.out.println("Accumulated Amount: " + (interest + p));
       }else {
           System.out.println("All Values should be positive");
       }
   }
}

Following is the snippet of the output.


So as to make sure that the user does not repeat the mistake of putting the wrong values as the input the code is printing the error if the wrong values are given. That the values should be positive.

Following is the snippet for the same.

That was a nice question to answer
Friend, If you have any doubts in understanding do let me know in the comment section. I will be happy to help you further.
Thanks

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C CODE PLZ! All instructions are in sections of code #include <stdio.h> /* TODO: Define 3...
C CODE PLZ! All instructions are in sections of code #include <stdio.h> /* TODO: Define 3 functions input, gcd and lcm in such a way that the main function below compiles correctly and has the correct behavior. The input function prompts the user to enter a non-negative integer. If the user enters a negative integer, the function prints a "sorry" statement and prompts the user again. It keeps on prompting until the user enters a non-negative number. The input function...
Python code only! (Do not include breaks or continue functions) Write a program that asks the...
Python code only! (Do not include breaks or continue functions) Write a program that asks the user to enter the amount that they budgeted for the month. A loop should then prompt the user to enter their expenses, one at a time and to enter 0 to quit. When the loop finishes, the program should display the the amount of budget left. (a negative number indicates the user is over budget and a positive number indicates the user is under...
There are 7 syntax errors and 3 semantic errors in the following code segment. Please mark...
There are 7 syntax errors and 3 semantic errors in the following code segment. Please mark them in the code and explain the reason briefly in place. #include<iostream> using namespace std; int main() { cout<<”Please input the radius (in integer): ”>>endl; int 1var = 10, var=20; double area = 40; cin<< var; //get an input of the radius and store in var float continue; float const pi = 2.64; pi += 0.5; do { cout<<”The radius is ”<<”var”<<endl; //print the...
Problem: Certain mathematical problems involve manipulation of the digits within a whole number. One such problem...
Problem: Certain mathematical problems involve manipulation of the digits within a whole number. One such problem requires that the digits be re-arranged.In this project, we will reverse the order of the digits in a number. Assignment: Design, develop, and test an Object-Oriented C++program that reads a whole number from the user, removes the sign and all leading and trailing zeroes from that number, and then performs the following operations on that number: 1) reverses the digits, 2) sorts the digits...
C++. Write a program that draws a rocket shape on the screen based on user input...
C++. Write a program that draws a rocket shape on the screen based on user input of three values, height, width and stages. The type of box generated (i.e.. a hollow or filled-in) is based on a check for odd or even values input by the user for the box height (or number of rows). Here is the general specification given user input for the height of the box..... Draw a hollow box for each stage if the value for...
Suppose we know that output in the economy is given by the production function: Yt =...
Suppose we know that output in the economy is given by the production function: Yt = At Kt(1/3) Lt(2/3) A.  Use partial derivative techniques to solve for the marginal product of capital. (Remember, it is an equation and NOT a single number). You must show your work, don’t just simply copy the answer from the book or lectures. B. Explain what happens to the MPK as K is increased. Make sure your explanation includes a behavioral rather than just mathematical explanation....
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
Assignment Overview This programming exercise introduces generics and interfaces. The students must create methods that accept...
Assignment Overview This programming exercise introduces generics and interfaces. The students must create methods that accept generic parameters and perform operation on them. Deliverables A listing of the fully commented, working source code of the Java program Test data for the code A screen shot of the application in execution Step 1 Create a new project. Name it "Assignment_2_1". Step 2 Build a solution. Write the Java source code necessary to build a solution for the problem below:You have just...
JAVA Learning Objectives: To be able to code a class structure with appropriate attributes and methods....
JAVA Learning Objectives: To be able to code a class structure with appropriate attributes and methods. To demonstrate the concept of inheritance. To be able to create different objects and use both default and overloaded constructors. Practice using encapsulation (setters and getters) and the toString method. Create a set of classes for various types of video content (TvShows, Movies, MiniSeries). Write a super or parent class that contains common attributes and subclasses with unique attributes for each class. Make sure...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...