translate this into java code :
This class contains the main method.
Create a Scanner to read in data from the terminal
Request and read in the name of the portfolio.
Request and read n a seed.
Create a Portfolio object with the portfolio name and seed.
Call initializePortfolio for the Portfolio object.
Request and read in the number of months to model.
Call modelPortfolio for the Portfolio object with the number of months.
Call generatePortfolioReport for the Portfolio object with the number of months.
Here is the solution to above problem. Please refer to code screenshot for indentation help and read code comments for more information
JAVA CODE
import java.io.*;
import java.util.*;
//class Portfolio
class Portfolio
{
//name of Portfolio
public String name;
//seed for Portfolio
public String seed;
//initializing Portfolio
public Portfolio(String name,String seed)
{
this.name = new String();
this.seed= new String();
this.name = name;
this.seed = seed;
}
//model Portfolio
public void modelPortfolio(int months)
{
System.out.println("THIS METHOD CAN GENERATE PORFOLIO MODEL for "+
months+ " many months");
System.out.println("PORFOLIO: "+this.name);
System.out.println("SEED: "+ this.seed);
}
//generateReport
public void generateReport(int months)
{
System.out.println("THIS METHOD CAN GENERATE PORTFOLIO REPORT for
"+ months+ " many months ");
System.out.println("PORFOLIO: "+this.name);
System.out.println("SEED: "+ this.seed);
}
}
public class Main
{
public static void main(String[] args) {
Scanner sc= new
Scanner(System.in);
//taking input
System.out.println("Enter Portfolio
name: ");
String name = sc.nextLine();
System.out.println("Enter Portfolio
Seed: ");
String seed = sc.nextLine();
//initializing object
Portfolio P = new
Portfolio(name,seed);
//taking input
System.out.println("Enter number of
months: ");
int months = sc.nextInt();
//model Portfolio method
P.modelPortfolio(months);
//model generateReport
P.generateReport(months);
}
}
OUTPUT OF CODE

SCREENSHOT OF THE CODE


translate this into java code : This class contains the main method. Create a Scanner to...
Java : Please help me correct my code: create a single class (Program11.java) with a main method and some auxiliary methods to input a 2-D array from a disk file, input some “transactions” to change the 2-D array and output the changed 2-D array to another file. Your main method will be minimal (see below). Most of the work will go on in your methods. In main, declare (but do not instantiate) 2-D array. Then call the three methods. The...
Create a CalculatorTest class that contains the main method. 1. Get two double numbers as input and create an object of the ScientificCalculator Class with those two numbers. 2. Then call the 8 operations one by one sequentially and display the result. Code must be written in Java. (Sample input/output: Enter number 1: 2 Enter number 2: 3 Add() result is : 5 Sub() result is: -1 ……. Power() result is: 8 …… sqrtNum1 result is:) The Problem: Given the...
JAVA This PoD, builds off the Book class that you created on Monday (you may copy your previously used code). For today’s problem, you will add a new method to the class called lastName() that will print the last name of the author (you can assume there are only two names in the author name – first and last). You can use the String spilt (“\s”) method that will split the String by the space and will return an array...
This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This program will use the ArrayManager class. The final version of the program is described below, but initially use it to test your ArrayManager class as you write it. Complete the ArrayManager class as specified below: The class will have exactly two instance variables: An array of integers A count of the number of elements currently in the array The class will have...
(Java with Netbeans) Programming. Please show modified
programming code for already given Main class, and programming for
code for the new GameChanger class.
// the code for Main class for step number 6 has already
been given, please show modified progrraming for Main class and
GameCHanger class, thank you.
package .games;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
System.out.println("Welcome to the Number Guessing Game");
System.out.println();
Scanner sc = new Scanner(System.in);
// Get upper...
PrintArray vi Create a class called PrintArray. This is the class that contains the main method. Your program must print each of the elements of the array of ints called aa on a separate line (see examples). The method getArray (included in the starter code) reads integers from input and returns them in an array of ints. Use the following starter code: //for this program Arrays.toString(array) is forbidden import java.util.Scanner; public class PrintArray { static Scanner in = new Scanner(System.in);...
1) Create a main() method with a switch statement that calls either a sum() OR factorial() method, depending on what selection the user of the program makes - ask the user to enter a selection (with System.out.println()), create a Scanner then read the user's input with a call to Scanner next(), then call the appropriate method in a switch (the String that was read from the call to Scanner.next() should be what you use as your switch condition). 2) Create...
LE 7.2
Purpose: To learn how to create and use stand-alone class programs (classes withouta main method). When you take code out of the application class and put it in a class of its own, you make it reusable Prep Work: Chapter 7 Figure 7.6 shows you how an application class uses the services of a Java class in Figure 7.5. Although the code for LE 7.2 is different than the code in these figures, the concept is the same....
Java: Create a main method for your class, and then add another method to your class (above the main method) named fallingDistance. This method accepts an integer into its parameter t, which is the amount of time, in seconds, that an object has been falling. This method returns the distance, in meters, that the object has fallen during the time interval. When an object s falling because of gravity, we use the following formula to determine the distance the object...
Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method, but for now leave it empty. Then write a Java method getAverage which takes an array of integers as it’s argument. The method calculate the average of all the elements in the array, and returns that average. The method should work for an array of integers of any length greater than or equal to one. The method signature is shown below: public static double getAverage(...