Question

In: Computer Science

In the assignment below please fix the errors in each code. The first code should have...

In the assignment below please fix the errors in each code. The first code should have a total of 3 erros. The second and third code should have 4 errors. Thanks

//DEBUG05-01
// This program is supposed to display every fifth year
// starting with 2017; that is, 2017, 2022, 2027, 2032,
// and so on, for 30 years.
// There are 3 errors you should find.
start
   Declarations
      num year
      num START_YEAR = 2017
      num FACTOR = 5
      num END_YEAR = 30
   year = START_YEAR
   while year <= END_YEAR
      output year
   endif
stop


//DEBUG05-02
// A standard mortgage is paid monthly over 30 years.
// This program is intended to output 360 payment coupons
// for each new borrower at a mortgage company.
// Each coupon lists the month number, year number,
// and a friendly mailing reminder.
// There are 4 errors here.
start
   Declarations
      num MONTHS = 12
      num YEARS = 30
      string MSG = "Remember to allow 5 days for mailing"
      num acctNum
      num yearCounter
   housekeeping()
   while acctNUm <> QUIT
      printCoupons()
   endwhile
   finish()
stop

housekeeping()
   print "Enter account number or ", QUIT, " to quit "
   input acctNum
return

printCoupons()
   while yearCounter <= YEARS
      while monthCounter <= MONTHS
         print acctNum, monthCounter, yearCounter, MSG
         monthCounter = monthCounter + 1
      endwhile
   endwhile
   output "Enter account number or ", QUIT, " to quit "
   input acctNum
return

finish()
   output "End of job"
return


//DEBUG05-03
// This program displays every combination of three-digits
// There are 4 errors here.
start
   Declarations
     num digit1 = 0
     num digit2 = 0
     num digit3 = 0
   while digit1 <= 9
      while digit2 <= 9
         while digit3 <= 9
            output digit1, digit2, digit3
            digit1 = digit1 + 1
         endwhile
         digit2 = digit2 + 1
      endwhile
      digit3 = digit3 + 1
   endwhile
stop

Solutions

Expert Solution

Note: In the below codes , error coorection have been shown by the bold letteres.

Debug 1:

start
   Declarations
      num year
      num START_YEAR = 2017
      num FACTOR = 5
      num END_YEAR = START_YEAR + FACTOR*29
   year = START_YEAR
   while year <= END_YEAR

year=year + 5
      output year
   endwhile
stop

Debug 2:

start
   Declarations
      num MONTHS = 12
      num YEARS = 30
      string MSG = "Remember to allow 5 days for mailing"
      num acctNum
      num yearCounter=1

num monthCounter=1
   housekeeping()
   while acctNum<> QUIT
      printCoupons()
   endwhile
   finish()
stop

housekeeping()
   print "Enter account number or ", QUIT, " to quit "
   input acctNum
return

printCoupons()
   while yearCounter <= YEARS
      while monthCounter <= MONTHS
         print acctNum, monthCounter, yearCounter, MSG
         monthCounter = monthCounter + 1
      endwhile

yearCounter= yearCounter+1
   endwhile
   output "Enter account number or ", QUIT, " to quit "
   input acctNum
return

finish()
   output "End of job"
return

Debug 3:

start
   Declarations
     num digit1 = 0
     num digit2 = 0
     num digit3 = 0
   while digit1 <= 9
      while digit2 <= 9
         while digit3 <= 9
            output digit1, digit2, digit3
            digit3 = digit3 + 1
         endwhile
         digit2 = digit2 + 1

digit3 = 0
      endwhile
      digit1 = digit1 + 1

digit2= 0
   endwhile
stop

Note: if you know the "c" language and want to implement these codes on your own, the screenshots of code in the "c" language is attached for the first and last question, otherewise leave this portion.


Related Solutions

fix all errors in code below: PLEASE DO ASAP, THIS IS IN MATLAB %Welcome Message fprintf('****Welcome...
fix all errors in code below: PLEASE DO ASAP, THIS IS IN MATLAB %Welcome Message fprintf('****Welcome to Comida Mexicana De Mentiras****\n'); flag =0; while flag ==1 % Asking the user for the order choice = input('Please enter your order \n 1. Burrito Bowl \n 2.Burrito \n 3. Tacos \n Enter 1 or 2 or 3: ','s'); switch choice case choice==1 % For Burrito Bowl BaseCost = 4; [Protein, PC] = proteinChoice(); [FinalAmount,~]= AmountCalculator(BaseCost,PC); displayMessage("Burrito Bowl",Protein,FinalAmount); case choice==2 end end %...
Please fix all of the errors in this Python Code. import math """ A collection of...
Please fix all of the errors in this Python Code. import math """ A collection of methods for dealing with triangles specified by the length of three sides (a, b, c) If the sides cannot form a triangle,then return None for the value """ ## @TODO - add the errlog method and use wolf fencing to identify the errors in this code def validate_triangle(sides): """ This method should return True if and only if the sides form a valid triangle...
q7.1 Fix the errors in the code (in C) //This program should read a string from...
q7.1 Fix the errors in the code (in C) //This program should read a string from the user and print it using a character pointer //The program is setup to use pointer offset notation to get each character of the string #include <stdio.h> #include <string.h> int main(void){ char s[1]; scanf(" %c", s); char *cPtr = s[1]; int i=0; while(1){ printf("%c", cPtr+i); i++; } printf("\n"); }
The source code I have is what i'm trying to fix for the assignment at the...
The source code I have is what i'm trying to fix for the assignment at the bottom. Source Code: #include <iostream> #include <cstdlib> #include <ctime> #include <iomanip> using namespace std; const int NUM_ROWS = 10; const int NUM_COLS = 10; // Setting values in a 10 by 10 array of random integers (1 - 100) // Pre: twoDArray has been declared with row and column size of NUM_COLS // Must have constant integer NUM_COLS declared // rowSize must be less...
Need to fix this code for tc -tac-toe game .. see the code below and fix...
Need to fix this code for tc -tac-toe game .. see the code below and fix it #include <iostream> using namespace std; void display_board(); void player_turn(); bool gameover (); char turn ; bool draw = false; char board [3][3] = { {'1', '2', '3'}, { '4', '5', '6'}, { '7', '8', '9'}}; int main() { cout << " Lets play Tc- Tac- toe game " <<endl ; cout << " Player 1 [X] ----- player 2 [0] " <<endl <<endl;...
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner;...
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner; public class Booolean0p {        public class BooleanOp {            public static void main(String[] args) {                int a = 0, b = 0 , c = 0;                Scanner kbd = new Scanner(System.in);                System.out.print("Input the first number: ");                a = kbd.nextInt();                System.out.print("Input...
q7.4 Fix the errors in the code (in C) //This program is supposed to scan 5...
q7.4 Fix the errors in the code (in C) //This program is supposed to scan 5 ints from the user //Using those 5 ints, it should construct a linked list of 5 elements //Then it prints the elements of the list using the PrintList function #include <stdio.h> struct Node{ int data; Node* next; }; int main(void){ struct Node first = {0, 0}; struct Node* second = {0, 0}; Node third = {0, 0}; struct Node fourth = {0, 0}; struct...
in c++ please follow instructions and fix the errors and please make a comment next to...
in c++ please follow instructions and fix the errors and please make a comment next to each code error you fix. Below are 25 code fragments, inserted into a try catch block. Each line has zero or more errors. Your task is to find and remove all errors in each fragment. Do not fix problems by simply deleting a statement; repair the problems by changing, adding, or deleting a few characters. There may be different ways to fix them You...
Can you fix the errors in this code? import java.util.Scanner; public class Errors6 {    public...
Can you fix the errors in this code? import java.util.Scanner; public class Errors6 {    public static void main(String[] args) {        System.out.println("This program will ask the user for three sets of two numbers and will calculate the average of each set.");        Scanner input = new Scanner(System.in);        int n1, n2;        System.out.print("Please enter the first number: ");        n1 = input.nextInt();        System.out.print("Please enter the second number: ");        n2 =...
1.The below code has some errors, correct the errors and post the working code. Scanner console...
1.The below code has some errors, correct the errors and post the working code. Scanner console = new Scanner(System.in); System.out.print("Type your name: "); String name = console.nextString(); name = toUpperCase(); System.out.println(name + " has " + name.Length() + " letters"); Sample Ouptut: Type your name: John JOHN has 4 letters    2. Write a code that it reads the user's first and last name (read in the entire line as a single string), then print the last name   followed by...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT