need help with reformatting-shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers need help with reformatting-shell script
# 1  
Old 11-09-2010
need help with reformatting-shell script

Folks, I need a shell script that reformat the code for easier reading. Any help will be greatly appreciated.

Code:
   #include <stdio.h>
   #include <       >	


public class AnthonyWhiteProg4
{
    Scanner stdIn = new Scanner(System.in);
    double speed;     
                                         
    double distance;                                           
    double stoppingDistance = speed * (2.25 + speed/21);       
    System.out.print("Enter your speed (mph): ");
    speed.stdIn.nextDouble();
    System.out.print("Enter your tailgate distance: ");
    stoppingDistance.stdIn.nextDouble(); 
    if(stoppingDistance==tailGatingDistance){
    if (system.out.println("Minor wreck"))
    { 
    stoppingdistance > tailGatingDistance;
    }
    }
    System.out.println("Major wrek"); 

}



The output should look like this:

#include <stdio.h>
#include <       >
public class AnthonyWhiteProg4
{
    Scanner stdIn = new Scanner(System.in);
    double speed;                                              
    double distance;                                           
    double stoppingDistance = speed * (2.25 + speed/21);       
    System.out.print("Enter your speed (mph): ");
    speed.stdIn.nextDouble();
    System.out.print("Enter your tailgate distance: ");
    stoppingDistance.stdIn.nextDouble(); 
    if(stoppingDistance==tailGatingDistance)
    {
	if (system.out.println("Minor wreck"))
	{ 
	  stoppingdistance > tailGatingDistance;
	}
    }
    System.out.println("Major wrek"); 
}


Last edited by newzyer; 11-10-2010 at 12:03 AM..
# 2  
Old 11-09-2010
First, our editor only removes spaces in regular text. If you tell it to handle certain parts as code by using [CODE] tags it'll preserve all spaces and use a monospace font.

Second, you don't need a shell script for that (as it probably won't be able to handle it), but rather a program like indent, astyle, or perltidy (depending on language). Also, most IDEs come with a built-in source formatter.
# 3  
Old 11-10-2010
pludi thanks for the info on tags.

This is part of an assignment and it has to be a shell script.
# 4  
Old 11-10-2010
Homework assignments go here, see Rule #6. Thread closed.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help reformatting column

Hello UNIX experts, I'm stumped finding a method to reformat a column. Input file is a two column tab-delimited file. Essentially, for every term that appears in column 2, I would like to summarize whether that term appears for every entry in column 1. In other words, make a header for each term... (2 Replies)
Discussion started by: torchij
2 Replies

2. UNIX for Dummies Questions & Answers

Need help in reformatting the input

Hi i want to print line which is mentioned as below 615213:1;20150725;20250722;0|11;20150831;20150831;100|14;20150725;20160723;2 in below format. ' 615213: 1;20150725;20250722;0 615213: 11;20150831;20150831;100 615213: 14;20150725;20160723;2 please help me and suggest me how to... (9 Replies)
Discussion started by: scriptor
9 Replies

3. UNIX for Dummies Questions & Answers

Date reformatting

I have been reformatting dates from a data file to make them mysql compliant. 31-10-2011 Loc1 1-11-2011 Loc2 The first can be captured by this: sed -i '' -e "s#\(..\)-\(..\)-\(....\)#\3-\2-\1#" data.txt and leads to: 2011-10-31 Loc1 The second line is captured as follows: sed -i... (2 Replies)
Discussion started by: figaro
2 Replies

4. UNIX for Dummies Questions & Answers

Date reformatting

I have a file with temperature measurements: Loc1,20090102,71.55 Loc1,20090103,71.65 Loc1,20090104,71.55 Loc1,20090105,71.54 Loc1,20090106,71.54 However, to load this into a database I would like to reformat the dates (column 2) from the yyyymmdd format to the yyyy-mm-dd format. I have... (2 Replies)
Discussion started by: figaro
2 Replies

5. UNIX for Dummies Questions & Answers

Date reformatting

I currently have the following file containing sample values for a number of dates: Loc1 04 Jan 2007 0.95 0.9532 Loc1 05 Jan 2007 0.95 0.9513 Loc1 06 Jan 2007 0.95 0.9535 This continues for all months of the year and spans across several years. I am trying to reformat the dates so that... (2 Replies)
Discussion started by: figaro
2 Replies

6. Shell Programming and Scripting

Help reformatting output

I have a command that gives me the output below: JAVA_HOME = C:/jdk1.5.0_11 Broker Performance Report for server 'app1' RMI_URL = rmis:// Parameter Kintana ItgDS DashboardDS ---------------------------- ------- ----- ----------- Connections count 41 ... (4 Replies)
Discussion started by: bwiebe
4 Replies

7. Shell Programming and Scripting

Searching pattern and reformatting

Hi, I have a file whose sample data is as below: Rak 654 JM30 20100215 387898263 7867556789 RPT 654 TM38 20100215 827384652 9786735628 RNP DCB 342 TM38 20100215 876782372 2323786527 Rak 654 JM30 20100215 328564893 8862573828 RNN 684 SK20 20100215 926738429 8283927457 RPP TKS 20100215... (10 Replies)
Discussion started by: rochitsharma
10 Replies

8. Shell Programming and Scripting

Reformatting Data in AWK

Dear AWK Users, I have a data set that is so large (Gigabytes) that it cannot be opened in the vi editor in its entirety. But I can manipulate the entire thing in AWK. It is formatted in a regular manner such that it has the variable descriptions or listings preceeding the variables. The latter... (13 Replies)
Discussion started by: sda_rr
13 Replies

9. UNIX for Dummies Questions & Answers

Reformatting file

Hi, How can I reformat a file (text file) using unix command. This file was FTP'd from Mainframe and contains some garbage character at the end of each line. Each line contains special characters '<soh>' at the end which should have been spaces when I view it in emacs or nedit. I couldnt do find... (2 Replies)
Discussion started by: mrjunsy
2 Replies

10. Filesystems, Disks and Memory

reformatting a floppy!

i am trying to reformat a floppy i am using solaris 9 when i run this: rmformat -F quick /vol/dev/aliases/floppy0 it tells me that it cannot perform the operation on a mounted device. how do i unmount the device and format the floppy? (1 Reply)
Discussion started by: rmuhammad
1 Replies
Login or Register to Ask a Question