Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in your company, your boss asked you to develop a program. this program can calc

ID: 3721069 • Letter: I

Question

in your company, your boss asked you to develop a program. this program can calculate the output voltage of an electric motor. you needs to model the fixed magnetic flied in which the motor coil roates. Assume that the motor windings are  circular, but the number of windings and their area can be changed. Each motor object should also have a rate of rotation stored as a field.

After a motor object was created,your boss wants to run a method that will calculate and return the EMF produced by the motor.

your also need to build a class containing an ArrayList of motor objects, so that boss can explore the effect of coil design on the output EMF. Your class should allow him to create any number of coils, and then simulate them at different locations for comparison.

Eg. The output might look like this (formatted with System.out.println)

Motor name

diameter

Num windings

Rotational speed (rev/s)

Produced EMF (V)

Motor name

diameter

Num windings

Rotational speed (rev/s)

Produced EMF (V)

Explanation / Answer

ElectricMotor.java

package com.chegg.tryouts;

public class ElectricMotor {

private String motorName;

private float motorDiameter;

private int numOfWindings;

private int numberOfCoils;

private float rateOfRotation;

private float generatedEMF;

public ElectricMotor(String motorName, float motorDiameter,

int numOfWindings, float rateOfRotation) {

super();

this.motorName = motorName;

this.motorDiameter = motorDiameter;

this.numOfWindings = numOfWindings;

this.rateOfRotation = rateOfRotation;

}

public ElectricMotor(String motorName, float motorDiameter,

int numOfWindings, float rateOfRotation, float generatedEMF) {

super();

this.motorName = motorName;

this.motorDiameter = motorDiameter;

this.numOfWindings = numOfWindings;

this.rateOfRotation = rateOfRotation;

this.generatedEMF = generatedEMF;

}

public String getMotorName() {

return motorName;

}

public void setMotorName(String motorName) {

this.motorName = motorName;

}

public float getGeneratedEMF() {

return generatedEMF;

}

public void setGeneratedEMF(float generatedEMF) {

this.generatedEMF = generatedEMF;

}

public float getMotorDiameter() {

return motorDiameter;

}

public int getNumberOfCoils() {

return numberOfCoils;

}

public void setNumberOfCoils(int numberOfCoils) {

this.numberOfCoils = numberOfCoils;

}

public void setMotorDiameter(float motorDiameter) {

this.motorDiameter = motorDiameter;

}

public int getNumOfWindings() {

return numOfWindings;

}

public void setNumOfWindings(int numOfWindings) {

this.numOfWindings = numOfWindings;

}

public float getRateOfRotation() {

return rateOfRotation;

}

public void setRateOfRotation(float rateOfRotation) {

this.rateOfRotation = rateOfRotation;

}

}

ElectricMotorList.java

package com.chegg.tryouts;

import java.util.ArrayList;

import java.util.List;

public class ElectricMotorList {

private List<ElectricMotor> listOfElectricMotorObjs = new ArrayList<ElectricMotor>();

public List<ElectricMotor> getListOfElectricMotorObjs() {

return listOfElectricMotorObjs;

}

public void setListOfElectricMotorObjs(

List<ElectricMotor> listOfElectricMotorObjs) {

this.listOfElectricMotorObjs = listOfElectricMotorObjs;

}

}

ElectricMotorTester.java

/**

*

*/

package com.chegg.tryouts;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

/**

* @author user

*

*/

public class ElectricMotorTester {

/**

* @param args

*/

public static void main(String[] args) {

List<ElectricMotor> emList= new ArrayList<ElectricMotor>();

System.out.println("**Welcome to the EMF Calculator App****");

Scanner sc=new Scanner(System.in);

System.out.println("Do you want to enter details for motors for EMF generation , press Y if yes:");

String isMotorDetailsRequired = sc.next();

while (isMotorDetailsRequired.equals("Y"))

{

System.out.println("Enter Details for the motor you want to calculate the EMF for :");

System.out.println("Name of the motor :");

String motorName = sc.next();

System.out.println("Enter Motor diameter :");

float motorDiameter = sc.nextFloat();

System.out.println("Enter number of windings in motor :");

int numberOfWindings = sc.nextInt();

System.out.println("Enter rate of rotation of the motor in rev/sec :");

float rateOfRoation = sc.nextFloat();

float generatedEMF = calculateEMF(motorName,motorDiameter,numberOfWindings,rateOfRoation,0); //Sending number of coils as 0 for the first section of the question

System.out.println("EMF for "+ " "+motorName+" is : " + generatedEMF+ " volts");

ElectricMotor em = new ElectricMotor(motorName,motorDiameter,numberOfWindings,rateOfRoation,generatedEMF);

emList.add(em);

System.out.println("============================================================");

System.out.println("Do you still want to enter details for motors for EMF generation , press Y if yes, any other character for No:");

isMotorDetailsRequired = sc.next();

}

if(emList.size()!=0){

System.out.println("******SUMMARY OF THE DETAILS ENTERED *******");

System.out.println("MotorName"+" "+"Diameter"+" "+"Number of Windings"+" "+"Rotational Speed(rev/s)"+" "+"Produced EMF (v)");

for(ElectricMotor em: emList){

System.out.println(em.getMotorName()+" "+em.getMotorDiameter()+" "+em.getNumOfWindings()+" "+em.getRateOfRotation()+" "+em.getGeneratedEMF());

}

System.out.println("Want to analyze effect of coil design on the output EMF ? press Y if yes");

String a = sc.next();

if(a.endsWith("Y")){

analyzeEffectOfCoilDesign(emList, sc);

}else{

System.out.println("Exiting Program, Thank You !!");

}

}else{

System.out.println("No details for motor have been entered");

}

}

private static void analyzeEffectOfCoilDesign(List<ElectricMotor> emList, Scanner sc) {

ElectricMotorList emListNew = new ElectricMotorList();

ElectricMotor em1 = emList.get(0);

System.out.println("EMF with 0 coils was :"+ em1.getGeneratedEMF());

System.out.println("Enter number of coils to see effect on generated EMF "+em1.getMotorName()+":");

int numberOfCoils = sc.nextInt();

float calEMFNew = calculateEMF(em1.getMotorName(),em1.getMotorDiameter(),em1.getNumOfWindings(),em1.getRateOfRotation(),numberOfCoils);

System.out.println("The new EMF after introduction of coils is :" + calEMFNew +" volts");

}

private static float calculateEMF(String motorName, float motorDiameter,

int numberOfWindings, float rateOfRoation, int numberOfCoils) {

float calculateEMF = 0;

if(numberOfCoils==0)

calculateEMF= (motorDiameter*numberOfWindings*rateOfRoation)/60;

else

calculateEMF = (motorDiameter*numberOfWindings*rateOfRoation)/(60*numberOfCoils);

return calculateEMF;

}

}