Anyone help with me with this assignment, you are calculating ROI and AnnualizedROI.
[First character of first name][First character of last name]
The ROI of your investment is: [calculated ROI in the 00.00 format]%
The annualized ROI of your investment is: [calculated annualized ROI in the 00.00 format]%
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
/* Type your code here. */
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
String firstName,lastName;
System.out.println("Enter your first Name: ");
firstName= scnr.nextLine();
System.out.println("Enter your Last Name: ");
lastName= scnr.nextLine();
double initialStockPrice, finalStockPrice, dividends, commissions;
int shares, holdingPeriod;
System.out.print("Enter initial Stock Price: $");
initialStockPrice= scnr.nextDouble();
System.out.print("Enter Final Stock Price: $");
finalStockPrice= scnr.nextDouble();
System.out.print("Enter number of shares holding: ");
shares = scnr.nextInt();
System.out.print("Enter dividend: $");
dividends= scnr.nextDouble();
System.out.print("Enter commissions: $");
commissions= scnr.nextDouble();
System.out.print("Enter Holding Period: ");
holdingPeriod= scnr.nextInt();
System.out.println(firstName.charAt(0)+" "+lastName.charAt(0));
//Calculate ROI
double ROI = ((((finalStockPrice-initialStockPrice)*shares)+dividends-(commissions))*100)/(initialStockPrice*shares);
System.out.print("The ROI of your investment is: "+String.format("%.2f",(double)Math.round(ROI))+"%");
//Calculating Annualized ROI
int n= holdingPeriod/360;
double AROI = Math.pow((1+ROI),(1/n))*100;
System.out.print("
The annualized ROI of your investment is: "+String.format("%.2f",(double)Math.round(AROI))+"%");
}
}
//output

//Thanks....................
Anyone help with me with this assignment, you are calculating ROI and AnnualizedROI. Receive the user's...
Can someone help me out with this? You are given a program that receives four lines in the below format, and stores them in str1, str2, str3, and num1. This is not a very long sentence. is long 4 Expand this program to: Write an if-elseif-else statement to print this line only if num1 is higher than 0: "Num1 is higher than 0!" print this line only if num1 is 0: "Num1 equals to 0!" And otherwise, print: ""Num1 is...
Finish FormatJavaProgram.java that prompts the user for a file name and assumes that the file contains a Java program. Your program should read the file (e.g., InputFile.java) and output its contents properly indented to ProgramName_Formatted.java (e.g., InputFile_Formatted.java). (Note: It will be up to the user to change the name appropriately for compilation later.) When you see a left-brace character ({) in the file, increase your indentation level by NUM_SPACES spaces. When you see a right-brace character (}), decrease your indentation...
C++ programming question, please help! Thank you so much in advance!!! In this exercise, you will work with 2 classes to be used in a RPG videogame. The first class is the class Character. The Character class has two string type properties: name and race. The Character class also has the following methods: a constructor Character(string Name, string Race), that will set the values for the name and the race variables set/get functions for the two attributes a function print(),...
Within DrJava, create a class called StudentQuizScores and do the following using a do-while loop. 1. You program will read in a student’s first name. The same will be done for the student’s last name. Your program will use respective methods (described below) to accomplish this. 2. Your program will then read in three quiz scores, respectively. This should be done by using the same method three times. This method is described below. 3. Your program will then calculate the...
Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...
You will need to think about problem solving. There are several multi-step activities. Design, compile and run a single Java program, StringEx.java, to accomplish all of the following tasks. Add one part at a time and test before trying the next one. The program can just include a main method, or it is neater to split things into separate methods (all static void, with names like showLength, sentenceType, lastFirst1, lastFirst), and have main call all the ones you have written...
Please help me. package a1; public class Methods { /* * Instructions for students: Use the main method only to make calls to the * other methods and to print some testing results. The correct operation of * your methods should not depend in any way on the code in main. * * Do not do any printing within the method bodies, except the main method. * * Leave your testing code...
For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java program that will input a file of sentences and output a report showing the tokens and shingles (defined below) for each sentence. Templates are provided below for implementing the program as two separate files: a test driver class containing the main() method, and a sentence utilities class that computes the tokens and shingles, and reports their values. The test driver template already implements accepting...
I have most of the code for this assignment but need some help getting the rest. Go to bottom to see what I have. Please help me figure out the foreach loops and the put() statement. In this assignment, you will be using a new data structure, HashMaps, to repeat Assignment 8.3. Main Method (5 points) Declare and initialize an HashMap with values of type of type Employee, and keys of type integer. In a while loop, keep initializing objects...
Please help and please satisfy the directions. The directions are
under program 3.
port JavaScore. public class Example 4 [ public static int getint String strum - JOptionPane.showinput Dialog("Enter an integer"); return integer.parseInt(strum): public static void main(String args Scanner input = new Scanner (System.in): System.out.println("Enter 2 integers"); intx input.nextInt(); inty input.nextInt(): 1/ these are simple is if b ) System.out.println("The first number is positive): if (0 y0) System.out.println("Both numbers are positive"); ( 11 y) System.out.println("At least one number is positive");...