Using assembler language For this assignment you will write a program that reads
ID: 3870974 • Letter: U
Question
Using assembler language
For this assignment you will write a program that reads in an unknown number of 2-digit numbers, 3 per line. For each line read, print out the numbers and the sum of the 3 numbers on the line (or record).
Each line has the following format:
cols 1-2 first number
cols 3-4 blank
cols 5-6 second number
cols 7-8 blank
cols 9-10 third number
cols 11-80 blank
When all processing is done, print the number of lines (or records) read as input and the grand total sum of all numbers.
Program incrementally! That means just read one record and print out those numbers. When that works, put in a loop. If you get one part working before moving on to the next, your debugging will be much easier and less time consuming.
Use a top driven loop:
READ FIRST RECORD
WHILE (NOT EOF) ß IF EOF BRANCH END LOOP
BODY OF LOOP
READ NEXT RECORD
BRANCH TO TOP OF LOOP
END LOOP
Use the following data for the run you turn in. You may (and should use your own data to test your program) This should be typed in your source file immediately after the END statement.
12 34 56
45 98 23
55 88 99
10 09 32
66 22 07
98 76 54
Explanation / Answer
import java.util.*;
import java.util.Scanner;
public class Digits{
public static void main(String[] args){
Scanner keyboard = new Scanner (System.in);
System.out.println ("Please enter an integer with up to 9 digits.");
Scanner keyboard = new Scanner(System.in);
number = keyboard.nextInt( );
System.out.println (number / 100000000);
System.out.println (number / 10000000);
System.out.println (number / 1000000);
System.out.println (number / 100000);
System.out.println (number / 10000);
System.out.println (number / 1000);
System.out.println (number / 100);
System.out.println (number / 10);
System.out.println (number % 10);
}
}
import java.util.*;
import java.util.Scanner;
public class Digits{
public static void main(String[] args){
int number;
Scanner keyboard = new Scanner (System.in);
System.out.println ("Please enter an integer with up to 9 digits.");
number = keyboard.nextInt( );
System.out.println (number / 100000000);
number = number % 100000000;
System.out.println (number / 10000000);
number = number % 10000000;
System.out.println (number / 1000000);
number = number % 1000000;
System.out.println (number / 100000);
number = number % 100000;
System.out.println (number / 10000);
number = number % 10000;
System.out.println (number / 1000);
number = number % 1000;
System.out.println (number / 100);
number = number % 100;
System.out.println (number / 10);
System.out.println (number % 10);
}
}
import java.util.Scanner;
public class vertorder {
public static void main(String[] args){
Scanner nums=new Scanner (System.in);
int num1;
int num2;
int numtotal;
System.out.println("Enter num1 between 1 and 50000 included:");
num1=nums.nextInt();
System.out.println("Enter num2 between 1 and 50000 included:");
num2=nums.nextInt();
if(num1<1 && num1>50000 && num2<1 && num2>50000){
System.out.println("You have entered a number out of the range specified,");
System.out.println("Please Enter both numbers between 1 and 50000 included:");
}
numtotal=num1+num2;
System.out.println(numtotal);
int a[]=new int [numtotal];
for(int i=0;i<numtotal;i++){
System.out.print(a[i]);
System.out.print(" ");
}
}
}
import java.util.Scanner;
public class vertorder {
public static void main(String[] args){
Scanner nums=new Scanner (System.in);
int num1;
int num2;
int numtotal;
System.out.println("Enter num1 between 1 and 50000 included:");
num1=nums.nextInt();
System.out.println("Enter num2 between 1 and 50000 included:");
num2=nums.nextInt();
if(num1<1 || num1>50000 || num2<1 || num2>50000){
System.out.println("You have entered a number out of the range specified! ");
System.out.println("Please Enter both numbers between 1 and 50000 included: ");
}
while(num1<1 || num1>50000 || num2<1 || num2>50000){
System.out.println("Enter num1 between 1 and 50000 included:");
num1=nums.nextInt();
System.out.println("Enter num2 between 1 and 50000 included:");
num2=nums.nextInt();
if(num1<1 || num1>50000 || num2<1 || num2>50000){
System.out.println("You have entered a number out of the range specified! ");
System.out.println("Please Enter both numbers between 1 and 50000 included: ");
}
}
numtotal=num1+num2;
System.out.println(numtotal);
String s1=String.format("%d",numtotal);
for(int i=0;i<s1.length();i++){
System.out.println(s1.charAt(i));
}
}
}
int num1 = -1;
int num2 = -1;
int numtotal;
while(num1<1 || num1>50000 || num2<1 || num2>50000){
System.out.println("Enter num1 between 1 and 50000 included:");
num1=nums.nextInt();
System.out.println("Enter num2 between 1 and 50000 included:");
num2=nums.nextInt();
if(isValid(num1) && isValid(num2)){
System.out.println("You have entered a number out of the range specified! ");
System.out.println("Please Enter both numbers between 1 and 50000 included: ");
}
}
#include<stdio.h>
int main()
{
int t,i,a[100],n,num;
/*I'm assuming that there are max 100 integers per line
variable i will store the number of integers read successfully so far*/
char ch,sign;
scanf("%d",&t);
getchar();
/*here getchar() will clears out the ' ' in the input buffer
which was left out while reading t*/
while(t--)
{
i=0;num=0;sign='+';
while(scanf("%c",&ch)==1)
{
if(ch=='-')sign='-';
else if(ch==' ' || ch==' ')
{
if(sign=='-')
{num=-num;sign='+';}
a[i++] = num;
num=0;
if(ch==' ')break;
}
else num = 10*num + (ch-'0');
}
n=i;
/*now we have successfully stored all numbers in a
and the number of numbers in n*/
for(i=0;i < n;++i)
printf("%d ",a[i]);
putchar(' ');
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.