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

Print a double array sequence with this input // File DoubleArraySeqDemonstratio

ID: 3593227 • Letter: P

Question

Print a double array sequence with this input // File DoubleArraySeqDemonstration.java // This demonstration program shows how to use the DoubleArraySeq class // from the edu.colorado.homework.
public class DoubleArraySeqDemonstration { public static void main(String[ ] args) { DoubleArraySeq s = new DoubleArraySeq(1); for (double element = 1.0; element < 11.0; element += 1.0) s.addAfter(element); System.out.println("sequence s"); s.print();
DoubleArraySeq t = s.clone(); t.start(); for (int i = 0; i < 4; i++) t.advance(); t.addAfter(11.0); t.addAfter(12.0); System.out.println("sequence t after adding 11.0 and 12.0 to s"); t.print();
DoubleArraySeq u = t.clone(); u.start(); for (int i = 0; i < 5; i++) u.advance(); u.removeCurrent(); u.removeCurrent(); System.out.println("sequence u after removing 11.0 and 12.0 from t"); u.print();
DoubleArraySeq v = s.clone(); v.start(); for (int i = 0; i < 4; i++) v.advance(); v.addBefore(11.0); v.addBefore(12.0); System.out.println("sequence v after adding 11.0 and 12.0 to s"); v.print(); v.trimToSize(); System.out.println("sequence v after trim"); v.print(); v.addAll(s); System.out.println("sequence v = v + s"); v.print();    DoubleArraySeq w; w = DoubleArraySeq.concatenation(s,t); System.out.println("sequence w = s + t"); w.print();    DoubleArraySeq x = new DoubleArraySeq(); System.out.println("sequence x is empty"); x.print(); System.out.println("Trying to get anything from x causes an exception "); System.out.printf("%5.2f", x.getCurrent()); }
Print a double array sequence with this input // File DoubleArraySeqDemonstration.java // This demonstration program shows how to use the DoubleArraySeq class // from the edu.colorado.homework.
public class DoubleArraySeqDemonstration { public static void main(String[ ] args) { DoubleArraySeq s = new DoubleArraySeq(1); for (double element = 1.0; element < 11.0; element += 1.0) s.addAfter(element); System.out.println("sequence s"); s.print();
DoubleArraySeq t = s.clone(); t.start(); for (int i = 0; i < 4; i++) t.advance(); t.addAfter(11.0); t.addAfter(12.0); System.out.println("sequence t after adding 11.0 and 12.0 to s"); t.print();
DoubleArraySeq u = t.clone(); u.start(); for (int i = 0; i < 5; i++) u.advance(); u.removeCurrent(); u.removeCurrent(); System.out.println("sequence u after removing 11.0 and 12.0 from t"); u.print();
DoubleArraySeq v = s.clone(); v.start(); for (int i = 0; i < 4; i++) v.advance(); v.addBefore(11.0); v.addBefore(12.0); System.out.println("sequence v after adding 11.0 and 12.0 to s"); v.print(); v.trimToSize(); System.out.println("sequence v after trim"); v.print(); v.addAll(s); System.out.println("sequence v = v + s"); v.print();    DoubleArraySeq w; w = DoubleArraySeq.concatenation(s,t); System.out.println("sequence w = s + t"); w.print();    DoubleArraySeq x = new DoubleArraySeq(); System.out.println("sequence x is empty"); x.print(); System.out.println("Trying to get anything from x causes an exception "); System.out.printf("%5.2f", x.getCurrent()); }
// File DoubleArraySeqDemonstration.java // This demonstration program shows how to use the DoubleArraySeq class // from the edu.colorado.homework.
public class DoubleArraySeqDemonstration { public static void main(String[ ] args) { DoubleArraySeq s = new DoubleArraySeq(1); for (double element = 1.0; element < 11.0; element += 1.0) s.addAfter(element); System.out.println("sequence s"); s.print();
DoubleArraySeq t = s.clone(); t.start(); for (int i = 0; i < 4; i++) t.advance(); t.addAfter(11.0); t.addAfter(12.0); System.out.println("sequence t after adding 11.0 and 12.0 to s"); t.print();
DoubleArraySeq u = t.clone(); u.start(); for (int i = 0; i < 5; i++) u.advance(); u.removeCurrent(); u.removeCurrent(); System.out.println("sequence u after removing 11.0 and 12.0 from t"); u.print();
DoubleArraySeq v = s.clone(); v.start(); for (int i = 0; i < 4; i++) v.advance(); v.addBefore(11.0); v.addBefore(12.0); System.out.println("sequence v after adding 11.0 and 12.0 to s"); v.print(); v.trimToSize(); System.out.println("sequence v after trim"); v.print(); v.addAll(s); System.out.println("sequence v = v + s"); v.print();    DoubleArraySeq w; w = DoubleArraySeq.concatenation(s,t); System.out.println("sequence w = s + t"); w.print();    DoubleArraySeq x = new DoubleArraySeq(); System.out.println("sequence x is empty"); x.print(); System.out.println("Trying to get anything from x causes an exception "); System.out.printf("%5.2f", x.getCurrent()); } // File DoubleArraySeqDemonstration.java // This demonstration program shows how to use the DoubleArraySeq class // from the edu.colorado.homework.
public class DoubleArraySeqDemonstration { public static void main(String[ ] args) { DoubleArraySeq s = new DoubleArraySeq(1); for (double element = 1.0; element < 11.0; element += 1.0) s.addAfter(element); System.out.println("sequence s"); s.print();
DoubleArraySeq t = s.clone(); t.start(); for (int i = 0; i < 4; i++) t.advance(); t.addAfter(11.0); t.addAfter(12.0); System.out.println("sequence t after adding 11.0 and 12.0 to s"); t.print();
DoubleArraySeq u = t.clone(); u.start(); for (int i = 0; i < 5; i++) u.advance(); u.removeCurrent(); u.removeCurrent(); System.out.println("sequence u after removing 11.0 and 12.0 from t"); u.print();
DoubleArraySeq v = s.clone(); v.start(); for (int i = 0; i < 4; i++) v.advance(); v.addBefore(11.0); v.addBefore(12.0); System.out.println("sequence v after adding 11.0 and 12.0 to s"); v.print(); v.trimToSize(); System.out.println("sequence v after trim"); v.print(); v.addAll(s); System.out.println("sequence v = v + s"); v.print();    DoubleArraySeq w; w = DoubleArraySeq.concatenation(s,t); System.out.println("sequence w = s + t"); w.print();    DoubleArraySeq x = new DoubleArraySeq(); System.out.println("sequence x is empty"); x.print(); System.out.println("Trying to get anything from x causes an exception "); System.out.printf("%5.2f", x.getCurrent()); }

Explanation / Answer

The following is the output of each string as per the code above

string s- 1,2,3,4,5,6,7,8,9,10 (sequence from 1 to 10 added after each element)
string t -1,2,3,4,5,6,7,8,9,10,11,12,11,12,11,12,11,12 ( 11,12 added after the earlier sequence looped 4 times)
string u -1,2,3,4,5,6,7,8( all elements added to string t from 9 are removed - sequence looped 5 times)
string v -1,2,3,4,5,6,7,8,9,11,12,11,12,11,12,11,12,10,1,2,3,4,5,6,7,8,9,10 ( 11,12 added before 10 looped 4 times and string s added to string v
string w- 1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,11,12,11,12,11,12,11,12 (w formed after concatinating s &t)
string x = 000.00 (string x is empty string typecasted to float with a total of 5 digits , with 2 digits after decimal places

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote