What if we want to input all the scoring data (average of the judge's scores for different categories) into our computer for a list of puppers? How can we write a program to find all the good dogs? Parallel arrays might be a good start.
For example, in JavaScript:
// Data on the dog's application (strings)
var names = ["Aaron", "Barko", "Chilly", "Dog", "Ester", "Froufrou"];
var genders = ["boy", "boy", "girl", "dog", "girl", "girl"]
var breeds = ["Poodle", "Boxer", "Mini-Pen", "Lab", "Chihauhau", "Mix"];
// Data from the dog's score (doubles)
var sits = [9.8, 7.2, 8.2, 1.3, 9.4, 8.9];
var stays = [7.3, 8.1, 7.0, 1.1, 6.0, 8.5];
var cuddles = [3.0, 6.2, 5.5, 9.9, 6.4, 8.6];
// Who is a good dog? Let's say anyone with a 5+ on all three scores
for (var i=0; i < names.length; ++i){
console.log("Is "+names[i]+" the "+breeds[i]+
" a good "+genders[i]+"?");
if (sits[i] >= 5.0 && stays[i] >= 5.0 && cuddles[i] >= 5.0){
console.log("Yes! "+names[i]+" the "+breeds[i]+
" is a good "+genders[i]+"!");
} else {
console.log("Well, not this year...");
}
}
names
array. At what index would you find your grade for lab 2 in the lab2s
array? Why?fetches
and populate it with whatever values (doubles between zero and ten) that you want. How could you update your logic to say anyone with a 5+ on any two scores is a good dog? Demonstrate with screenshots.