Java Programming: Solving Problems with Software Quiz Answers 2021

About Java Programming: Solving Problems with Software Course

Learn to code in Java and improve your programming and problem-solving skills. You will learn to design algorithms as well as develop and debug programs. Using custom open-source classes, you will write programs that access and transform images, websites, and other types of data.

At the end of the course, you will build a program that determines the popularity of different baby names in the US over time by analyzing comma-separated value (CSV) files.

Enroll in Java Programming: Solving Problems with Software

Java Programming: Solving Problems with Software Week 1 Quiz Answers

Quiz: Calculating the Perimeter of a Shape

Q1. What is the perimeter of the shape made from the file datatest4.txt whose contents are shown below (Truncate your answer to two decimal places)?

-3, 9

-8, 7

-12, 4

-6, -2

-4, -6

2, -8

6, -5

10, -3

8, 5

4, 81

  • correct Answers =59.45

Q2. What is the average length of a side in the shape made from the file datatest4.txt whose contents are shown below (Truncate your answer to two decimal places)?

-3, 9

-8, 7

-12, 4

-6, -2

-4, -6

2, -8

6, -5

10, -3

8, 5

4, 81

  • correct Answers= 5.94

Q3. What is the longest side in the shape made from the file datatest4.txt whose contents are shown below (Truncate your answer to two decimal places)?

-3, 9

-8, 7

-12, 4

-6, -2

-4, -6

2, -8

6, -5

10, -3

8, 5

4, 81

  • Correct Answers= 8.48

Q4. What is the largest perimeter of a shape made from the shapes in files dataset1.txt, dataset2.txt, dataset3.txt, dataset4.txt, dataset5.txt, and dataset6.txt (Truncate your answer to two decimal places)?

  • correct Answers = dataset5.txt

Q5. What is the name of the file that has the shape with the largest perimeter from the four files example1.txt, example2.txt, example3.txt and example4.txt? 1 point

  • example1.txt
  • example2.txt
  • example3.txt
  • example4.txt

Q6. The method getNumPoints returns the number of points in a Shape s.

Which one of the following is NOT a correct implementation of getNumPoints?

public int getNumPoints (Shape s) { 
 int count = 0;  
for (Point p : s.getPoints()) {    
int newPoint = 1;    
count = count + newPoint;  
}  
return count;
}
 public int getNumPoints (Shape s) {  
int count = 0;  
for (Point p : s.getPoints()) {    
count = count + 1;  
}  
return count;
} 
  • correctAnswers :
 public int getNumPoints (Shape s) {  
int count = 0;  
for (Point p : s.getPoints()) {    
count = count + count;  
}  
return count;
} 

Q7. Consider the following code for the function mysteryShape that has one parameter a Shape s and calls the function getNumPoints from the assignment.

public double mysteryShape (Shape s) {  
double tmp = 0;  
for (Point p : s.getPoints()) {       
if (p.getX() > 0) {            
if (p.getY() < 0) {        
tmp = tmp + 1;      
}    
}  
}  
return tmp / getNumPoints(s);    
}  
  • Which one of the following best describes the purpose of this function?
  • The function computes the sum of those points from the Shape s that have a positive X or a negative Y.
  • The function computes the percentage of those points from the Shape s that have a positive X and a negative Y.
  • The function computes the percentage of those points from the Shape s that have a positive X or a negative Y.
  • The function computes the sum of those points from the Shape s that have a positive X and a negative Y.

Java Programming: Solving Problems with Software Week 2 Quiz Answers

Quiz: Strings in Java

Q1.  Consider finding all the YouTube links on a web page. What is the video for the second YouTube link on the web page http://www.dukelearntoprogram.com/course2/data/manylinks.html about?

  • Turkeys, Ducks and Quails

Q2. Consider the following mystery method.

Question 2

public String mystery(String dna) {  
int pos = dna.indexOf("T");  
int count = 0;  
int startPos = 0;  
String newDna = "";  
if (pos == -1) {    
return dna;  
}  
while (count < 3) {    
count += 1;    
newDna = newDna + dna.substring(startPos,pos);    
startPos = pos+1;    
pos = dna.indexOf("T", startPos);    
if (pos == -1) {      
break;    
}  
}  
newDna = newDna + dna.substring(startPos);  
return newDna;
}
  • The method mystery is given a string and it returns a string which is the same string but with the first three T’s removed

Q3. Use the following data file to answer this question: http://www.cs.duke.edu/~rodger/GRch38dnapart.fa. How many genes are in this file?

  • 69

Q4. Use the following data file to answer this question: http://www.cs.duke.edu/~rodger/GRch38dnapart.fa. How many genes in this file are longer than 60?

  • 23

Q5. Use the following data file to answer this question: http://www.cs.duke.edu/~rodger/GRch38dnapart.fa. How many genes in this file have cgRatio greater than 0.35?

  • 40

Q6. Use the following data file to answer this question which represents one long strand of DNA: http://www.cs.duke.edu/~rodger/GRch38dnapart.fa. How many times does the codon CTG appear in this strand of DNA?

  • 224

Q7. Use the following data file to answer this question: http://www.cs.duke.edu/~rodger/GRch38dnapart.fa. What is the length of the longest gene in the collection of genes found in this file?

  • 489

Java Programming: Solving Problems with Software Week 3 Quiz Answers

Quiz: CSV Files and Basic Statistics in Java

Q1. Run your program from the first lesson programming exercise Parsing Export Data on the file exportdata.csv.

How many countries export cocoa?

Note: You should only enter a one- or two-digit number representing the number of countries, with no other information included.

  • 17

Q2. Run your program from the first lesson programming exercise Parsing Export Data on the file exportdata.csv.

What is the name of the third country (on the third line of the output) listed whose exports are valued at one trillion US dollars or more?

(Hint: Their value in the CSV file should be greater than $999,999,999,999.)

  • Germany

Q3. Run your program developed in Parsing Weather Data to determine the lowest humidity in the file for June 29th, 2014 (weather-2014-06-29.csv).

What was the lowest humidity reading on that day?

Note: You should only enter your two-digit number result, with no other additional information included.

  • 40

Q4. Run your program from programming exercise Parsing Weather Data to determine the lowest humidity in the file for July 22nd, 2014 (weather-2014-07-22.csv).

At what time of day did that humidity occur?

(Refer to the time from the DateUTC column.)

  • 20:51:00

Q5. Run your program from programming exercise Parsing Weather Data to determine the lowest humidity reading in the entire year of 2013.

What was the lowest humidity reading?

Note: You should only enter your two-digit number result, with no other additional information included.

  • 16

Q6. Run your program from programming exercise Parsing Weather Data to determine the average temperature in Fahrenheit on August 10, 2013 (weather-2013-08-10.csv).

Give your answer with four decimal digits and truncate the rest.

  • 80.1964

Q7. Run your program from programming exercise Parsing Weather Data to determine the average temperature in Fahrenheit for those temperature readings when the humidity is greater than or equal to 80 on September 2, 2013 (weather-2013-09-02.csv).

Give your answer with three decimal digits and truncate the rest.

  • 72.593

Q8. Run your program from programming exercise Parsing Weather Data to determine which day of the year had the coldest temperature in 2013.

  • January 23, 2013

Q9. Run your program from programming exercise Parsing Weather Data on 2013 data.

What was the coldest temperature recorded in 2013?

Give your answer with one decimal digit. (For example: 10.0)

  • 19.0

Java Programming: Solving Problems with Software Week 4 Quiz Answers

Quiz: Baby Names

Q1. What is the rank of the girl’s name “Emily” in 1960?

  • 251

Q2. What is the rank of the boy’s name “Frank” in 1971?

  • 54

Q3. What is the girl’s name of rank 350 in 1980?

  • Mia

Q4. What is the boy’s name of rank 450 in 1982?

  • Forrest

Q5. Suppose Susan was born in 1972. Based on her name’s rank in 1972, what would her name be if she were born in 2014 (that is, what name in 2014 had the same rank that “Susan” had in 1972)?

  • Addison

Q6. Suppose Owen was born in 1974. Based on his name’s rank in 1974, what would his name be if he were born in 2014 (that is, what name in 2014 had the same rank that “Owen” had in 1974)?

  • Leonel

Q7. In which year from 1880 to 2014 does the girl’s name “Genevieve” have the highest rank (over all the data files)?

If there is more than one year with the highest rank, choose the earliest one.

  • 1914

Q8. In which year from 1880 to 2014 does the boy’s name “Mich” have the highest rank (over all the data files)?

If there is more than one year with the highest rank, choose the earliest one.

  • 1960

Q9. What is the average rank of the girl’s name “Susan” over all the data files?

Give the answer to two decimal places.

  • 173.51

Q10. What is the average rank of the boy’s name “Robert” over all the data files?

Give the answer to two decimal places.

  • 10.75

Q11. What is the total number of girls born in 1990 with names ranked higher than the girl’s name “Emily” in 1990?

Give the answer without any commas or decimal points.

  • Ans:- 323200

Q12. What is the total number of boys born in 1990 with names ranked higher than the boy’s name “Drew” in 1990?

Give the answer without any commas or decimal points.

  • 1498074

Get all Course Quiz Answers of Object Oriented Programming in Java Specialization

Course 01: Java Programming: Solving Problems with Software Quiz Answers

Course 02: Java Programming: Arrays, Lists, and Structured Data Quiz Answers

Course 03: Object Oriented Programming in Java Quiz Answers

Course 04: Data Structures and Performance Quiz Answers

Leave a Reply

error: Content is protected !!